private boolean listViewStatus() {
    boolean flag = false;
    AdapterView<?> listView = null;
    for (int i = 0; i < getChildCount(); i++) {
      View v = getChildAt(i);
      if (v instanceof AdapterView<?>) {
        listView = (AdapterView<?>) v;
      }
    }
    if (listView == null) { //
      return false;
    }
    int frist = listView.getFirstVisiblePosition();
    int last = listView.getLastVisiblePosition();

    View top = listView.getChildAt(0);
    View bottom = listView.getChildAt(listView.getChildCount() - 1);

    if (top != null && frist == 0 && top.getTop() == 0) { // 最顶端
      moveStatus = STATUS_REFRESH_TOP;
      flag = true;
    } else if (bottom != null
        && last >= (listView.getCount() - 1)
        && bottom.getBottom() == listView.getHeight()) { // 最底端
      moveStatus = STATUS_REFRESH_FOOTER;
      flag = true;
    } else {
      moveStatus = STATUS_REFRESH_NONE;
      flag = false;
    }
    return flag;
  }
  private boolean canListScroll(int direction) {
    AdapterView<?> absListView = (AdapterView<?>) mTargetView;
    final int itemCount = absListView.getCount();
    final int childCount = absListView.getChildCount();
    final int firstPosition = absListView.getFirstVisiblePosition();
    final int lastPosition = firstPosition + childCount;

    if (itemCount == 0) {
      return false;
    }
    if (direction > 0) {
      // Are we already showing the entire last item?
      if (lastPosition >= itemCount) {
        final View lastView = absListView.getChildAt(childCount - 1);
        if (lastView != null && lastView.getBottom() >= mTargetView.getHeight()) {
          return false;
        }
      }
    } else if (direction < 0) {
      // Are we already showing the entire first item?
      if (firstPosition <= 0) {
        final View firstView = absListView.getChildAt(0);
        if (firstView != null && firstView.getTop() >= 0) {
          return false;
        }
      }
    }
    return true;
  }
Beispiel #3
0
  private static boolean canAdapterViewScroll(AdapterView lv) {
    /* Force it to layout it's children */
    if (lv.getLastVisiblePosition() == -1) return false;

    /* We can scroll if the first or last item is not visible */
    boolean firstItemVisible = lv.getFirstVisiblePosition() == 0;
    boolean lastItemVisible = lv.getLastVisiblePosition() == lv.getCount() - 1;

    if (firstItemVisible && lastItemVisible && lv.getChildCount() > 0) {
      /* Or the first item's top is above or own top */
      if (lv.getChildAt(0).getTop() < lv.getPaddingTop()) return true;
      /* or the last item's bottom is beyond our own bottom */
      return lv.getChildAt(lv.getChildCount() - 1).getBottom()
          > lv.getHeight() - lv.getPaddingBottom();
    }

    return true;
  }
 public static void resetListViewSelection(AdapterView<?> adapterView) {
   for (int i = 0; i < adapterView.getChildCount(); i++) {
     View listItem = adapterView.getChildAt(i);
     TextView nameTextView = (TextView) listItem.findViewById(R.id.level_name_textview);
     nameTextView.setTextColor(Color.BLACK);
     TextView statsTextView = (TextView) listItem.findViewById(R.id.level_stats_textview);
     statsTextView.setTextColor(Color.BLACK);
   }
 }
  @SuppressWarnings("unused")
  @Override
  public void onItemClick(AdapterView<?> Parent, View view, int position, long id) {
    // TODO Auto-generated method stub
    int Itemposition = Parent.getSelectedItemPosition();

    int ChildCount = Parent.getChildCount();
    View view1 = Parent.getChildAt(position);

    ViewHolder holder = (ViewHolder) view.getTag();

    Txt01 = (String) holder.text01.getText();
    Txt02 = (String) holder.text02.getText();
    Txt03 = (String) holder.text03.getText();

    AlertDialog.Builder dial = new AlertDialog.Builder(this);
    dial.setTitle("Que voulez vous faire avec :" + "\"" + Txt03 + "\"");
    dial.setIcon(R.drawable.ad_question);
    CharSequence[] items = {"Afficher les details", "Copier le produit dans une note"};
    dial.setSingleChoiceItems(
        items,
        -1,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int item) {
            /* User clicked on a radio button do some stuff */
            if (item == 0) { // afficher les details
              detail = true;
            }
            if (item == 1) { // créer une nouvelle note avec ce
              // produit
              newNote = true;
            }
          }
        });
    dial.setPositiveButton(
        "Ok",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int id) {

            if (detail) { // on affiche le detail du produit
              gotoAffDetail(Txt01);
            }
            if (newNote) { // on supprime le produit
              // gotoSupprDetail(Txt01,Txt03);
              gotoCreateNewNote(Integer.parseInt(Txt01));
            }
          }
        });
    dial.show();
  }
Beispiel #6
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   String functionId = columnEntries.get(position).getId();
   currentFunctionId = functionId;
   if (oldFunctionId.equals(currentFunctionId)) return;
   oldFunctionId = currentFunctionId;
   for (int i = 0; i < parent.getChildCount(); i++) {
     RelativeLayout rl = (RelativeLayout) parent.getChildAt(i);
     if (i == position) {
       ((ImageView) rl.getChildAt(0)).setImageResource(R.drawable.phone_study_menu_select);
       ((TextView) rl.getChildAt(1)).setTextColor(Color.WHITE);
     } else {
       ((ImageView) rl.getChildAt(0)).setImageDrawable(null);
       ((TextView) rl.getChildAt(1)).setTextColor(Color.BLUE);
     }
   }
   index = 0;
   courses.clear();
   coursewares.clear();
   loadDataForView(functionId);
 }