Exemplo n.º 1
0
 public MQuery setSelection(int position) {
   if (view instanceof AdapterView) {
     AdapterView<?> alv = (AdapterView<?>) view;
     alv.setSelection(position);
   }
   return this;
 }
 public void onItemClick(AdapterView adapterview, View view, int i, long l) {
   adapterview = (android.support.v7.media.tItem) getItem(i);
   if (adapterview.tItem()) {
     adapterview.tItem();
     dismiss();
   }
 }
 public void onItemClick(
     AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong) {
   paramAdapterView = paramAdapterView.getAdapter().getItem(paramInt);
   if ((paramAdapterView instanceof Category)) {
     paramView = (Category) paramAdapterView;
     if (paramView.f() > 0) {
       AppData.a(EventIri.NearbyMoreCategoriesCategory, "category", paramView.d());
       paramAdapterView = new Intent(a.getIntent());
       paramAdapterView.putExtra("category", paramView);
       a.startActivityForResult(paramAdapterView, 101);
     }
   } else {
     return;
   }
   paramAdapterView = paramView;
   if (TextUtils.isEmpty(paramView.d())) {
     paramAdapterView = null;
   }
   if (PickCategory.a(a)) {
     AppData.a(EventIri.NearbyMoreCategoriesCategory, "category", paramAdapterView.d());
     a.startActivity(ActivityNearby.a(a, paramAdapterView.d(), paramAdapterView));
     return;
   }
   paramView = new Intent(a.getIntent());
   paramView.putExtra("category", paramAdapterView);
   a.setResult(-1, paramView);
   a.finish();
 }
    /** Handles the user selecting an item from the popup. */
    @Override
    public void onItemClick(
        AdapterView<?> parent, // The ListView
        View view, // The TextView that was clicked
        int position,
        long id) {
      if (DBG) log("RespondViaSmsItemClickListener.onItemClick(" + position + ")...");
      String message = (String) parent.getItemAtPosition(position);
      if (VDBG) log("- message: '" + message + "'");

      // The "Custom" choice is a special case.
      // (For now, it's guaranteed to be the last item.)
      if (position == (parent.getCount() - 1)) {
        // Take the user to the standard SMS compose UI.
        launchSmsCompose(mPhoneNumber);
      } else {
        // Send the selected message immediately with no user interaction.
        sendText(mPhoneNumber, message);

        // ...and show a brief confirmation to the user (since
        // otherwise it's hard to be sure that anything actually
        // happened.)
        final Resources res = mInCallScreen.getResources();
        String formatString = res.getString(R.string.respond_via_sms_confirmation_format);
        String confirmationMsg = String.format(formatString, mPhoneNumber);
        Toast.makeText(mInCallScreen, confirmationMsg, Toast.LENGTH_LONG).show();

        // TODO: If the device is locked, this toast won't actually ever
        // be visible!  (That's because we're about to dismiss the call
        // screen, which means that the device will return to the
        // keyguard.  But toasts aren't visible on top of the keyguard.)
        // Possible fixes:
        // (1) Is it possible to allow a specific Toast to be visible
        //     on top of the keyguard?
        // (2) Artifically delay the dismissCallScreen() call by 3
        //     seconds to allow the toast to be seen?
        // (3) Don't use a toast at all; instead use a transient state
        //     of the InCallScreen (perhaps via the InCallUiState
        //     progressIndication feature), and have that state be
        //     visible for 3 seconds before calling dismissCallScreen().
      }

      // At this point the user is done dealing with the incoming call, so
      // there's no reason to keep it around.  (It's also confusing for
      // the "incoming call" icon in the status bar to still be visible.)
      // So reject the call now.
      mInCallScreen.hangupRingingCall();

      dismissPopup();

      final PhoneConstants.State state = PhoneApp.getInstance().mCM.getState();
      if (state == PhoneConstants.State.IDLE) {
        // There's no other phone call to interact. Exit the entire in-call screen.
        PhoneApp.getInstance().dismissCallScreen();
      } else {
        // The user is still in the middle of other phone calls, so we should keep the
        // in-call screen.
        mInCallScreen.requestUpdateScreen();
      }
    }
Exemplo n.º 5
0
 public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
   Xlog.e(
       TAG,
       "arg0.getId(): "
           + arg1.getId()
           + " "
           + R.id.WiFi_RX_Channel_Spinner
           + " "
           + R.id.WiFi_Bandwidth_Spinner);
   if (arg0.getId() == R.id.WiFi_RX_Channel_Spinner) {
     if (EMWifi.sIsInitialed) {
       mChannel.mChannelSelect = mChannelAdapter.getItem(arg2);
       EMWifi.setChannel(mChannel.getChannelFreq());
     } else {
       showDialog(DIALOG_WIFI_ERROR);
     }
   } else if (arg0.getId() == R.id.WiFi_Bandwidth_Spinner) {
     mBandwidthIndex = arg2 < mBandwidth.length ? arg2 : mBandwidthIndex;
     if (mBandwidth[BW_INDX_ADVANCED].equals(
         mBandwidthSpinner.getSelectedItem().toString())) {
       mBandwidthIndex = BW_INDX_ADVANCED;
     }
     if (mBandwidthIndex == BW_INDX_ADVANCED) {
       onAdvancedBandwidthSelected();
     } else {
       updateChannels();
       findViewById(R.id.wifi_bandwidth_advanced_ll).setVisibility(View.GONE);
     }
   }
 }
Exemplo n.º 6
0
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
          for (int i = 0; i < serviceTypeArrayList.size(); i++) {
            if (i != position) {
              serviceTypeArrayList.get(i).setSelected(false);
            }
          }
          ImageView imgChecked;
          for (int i = 0; i < adapterView.getAdapter().getCount(); i++) {
            View v1 = adapterView.getChildAt(i);
            if (v1 != null) {
              imgChecked = (ImageView) v1.findViewById(R.id.service_type_imageView);
              imgChecked.setVisibility(View.GONE);
            }
          }
          imgChecked = (ImageView) view.findViewById(R.id.service_type_imageView);
          ServiceType serviceType = serviceTypeArrayList.get(position);

          if (!serviceType.isSelected()) {
            imgChecked.setVisibility(View.VISIBLE);
            serviceType.setSelected(true);
            new SharedPreferencesManager(BookServiceActivity.this)
                .setValue(Constant.VALUE_CURRENT_KEY, serviceType.getName());
          } else {
            imgChecked.setVisibility(View.VISIBLE);
          }
        }
        @Override
        public void onItemSelected(AdapterView<?> adapter, View view, int pos, long id) {
          if (modifyingSpinner) {
            return;
          }
          Tossup t = game.currTossup();
          String playerName = (String) adapter.getSelectedItem();

          // team a was selected
          if (adapter.getId() == R.id.teamaplayerspinner) {
            // team a won
            if (t.getWinnerTeam().equals(game.getTeamA())) {
              Player p = t.getWinnerTeam().getPlayer(playerName);
              t.setWinnerPlayer(p);
            }
            // team a lost
            else {
              Player p = t.getLoserTeam().getPlayer(playerName);
              t.setLoserPlayer(p);
            }
          }
          // team b was selected
          else {
            // team b won
            if (t.getWinnerTeam().equals(game.getTeamB())) {
              Player p = t.getWinnerTeam().getPlayer(playerName);
              t.setWinnerPlayer(p);
            }
            // team b lost
            else {
              Player p = t.getLoserTeam().getPlayer(playerName);
              t.setLoserPlayer(p);
            }
          }
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    // model!
    String[] data = new String[99];
    for (int i = 99; i > 0; i--) {
      data[99 - i] = i + " bottles of beer on the wall";
    }

    ArrayList<String> list =
        new ArrayList<String>(Arrays.asList(data)); // convert to ArrayList (so modifiable)
    // String[] data = downloadMovieData("Die Hard");

    // controller
    adapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.txtItem, list);

    // support ListView or GridView
    AdapterView listView = (AdapterView) findViewById(R.id.listView);
    listView.setAdapter(adapter);

    MovieDownloadTask task = new MovieDownloadTask();
    task.execute("Die Hard");
  }
 private void clickAdapterView(AdapterView parent) {
   final int position = parent.getPositionForView(MaterialRippleLayout.this);
   final long itemId = parent.getAdapter() != null ? parent.getAdapter().getItemId(position) : 0;
   if (position != AdapterView.INVALID_POSITION) {
     parent.performItemClick(MaterialRippleLayout.this, position, itemId);
   }
 }
Exemplo n.º 10
0
  private void setupViews() {

    mSearchEditText.addTextChangedListener(mTextWatcher);
    mSearchEditText.setImeActionLabel(getString(R.string.launch), EditorInfo.IME_ACTION_GO);
    mSearchEditText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            if (actionId == EditorInfo.IME_ACTION_GO) {
              Log.d("KEYBOARD", "ACTION_GO");
              return openFirstActivity();
            }
            return false;
          }
        });
    mSearchEditText.setOnKeyListener(
        new View.OnKeyListener() {
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                && (keyCode == KeyEvent.KEYCODE_ENTER)) {
              Log.d("KEYBOARD", "ENTER_KEY");
              return openFirstActivity();
            }
            return false;
          }
        });
    registerForContextMenu(mAppListView);

    ((GridView) mAppListView)
        .setOnScrollListener(
            new AbsListView.OnScrollListener() {
              @Override
              public void onScrollStateChanged(AbsListView view, int scrollState) {
                if (scrollState != SCROLL_STATE_IDLE) {
                  hideKeyboard();
                }
              }

              @Override
              public void onScroll(
                  AbsListView view,
                  int firstVisibleItem,
                  int visibleItemCount,
                  int totalItemCount) {}
            });
    //noinspection unchecked
    mAppListView.setAdapter(mArrayAdapter);

    mAppListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position >= mColumnCount) {
              launchActivity(mActivityInfos.get(position - mColumnCount));
            }
          }
        });
  }
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

    if (parent.getItemAtPosition(pos).equals("AP")) {

      Spinner apChoice = (Spinner) findViewById(R.id.subChoiceSpinner);
      ArrayAdapter<CharSequence> adapter1 =
          ArrayAdapter.createFromResource(
              this, R.array.apChoices_array, android.R.layout.simple_spinner_item);
      adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      apChoice.setAdapter(adapter1);
    } else if (parent.getItemAtPosition(pos).equals("Subject SAT")) {
      Spinner sat = (Spinner) findViewById(R.id.subChoiceSpinner);
      ArrayAdapter<CharSequence> adapter1 =
          ArrayAdapter.createFromResource(
              this, R.array.subjectSat_array, android.R.layout.simple_spinner_item);
      adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      sat.setAdapter(adapter1);
    } else if (parent.getItemAtPosition(pos).equals("School Subjects")) {
      Spinner schoolSubject = (Spinner) findViewById(R.id.subChoiceSpinner);
      ArrayAdapter<CharSequence> adapter1 =
          ArrayAdapter.createFromResource(
              this, R.array.schoolsubject_array, android.R.layout.simple_spinner_item);
      adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      schoolSubject.setAdapter(adapter1);
    }
  }
Exemplo n.º 12
0
 public MQuery itemClicked(OnItemClickListener listener) {
   if (view instanceof AdapterView) {
     AdapterView<?> alv = (AdapterView<?>) view;
     alv.setOnItemClickListener(listener);
   }
   return this;
 }
Exemplo n.º 13
0
  /**
   * 指定したAdapterViewの現在選択されているObjectを返します。
   *
   * @param view 検索対象のView
   * @param resId リソースID
   * @return 選択されている AdapterのgetItem()の返却値
   */
  protected Object getSelectedItem(View view, int resId) {
    if (view == null) {
      view = getView();
    }

    AdapterView<?> adapterView = (AdapterView<?>) view.findViewById(resId);
    return adapterView.getSelectedItem();
  }
Exemplo n.º 14
0
 // show loading view when init and loading data from network
 protected void showLoadingEmptyView() {
   if (mEmptyFailView == null) {
     mEmptyLoadingView = EmptyViewUtils.createLoadingView(this);
   }
   ((ViewGroup) listView.getParent()).removeView(mEmptyFailView);
   ((ViewGroup) listView.getParent()).addView(mEmptyLoadingView);
   listView.setEmptyView(mEmptyLoadingView);
 }
Exemplo n.º 15
0
 @SuppressWarnings({"unchecked", "rawtypes"})
 public MQuery adapter(Adapter adapter) {
   if (view instanceof AdapterView) {
     AdapterView av = (AdapterView) view;
     av.setAdapter(adapter);
   }
   return this;
 }
 public CursorAdapter getCursorAdapter() {
   final AdapterView<CursorAdapter> adapterView = getAdapterView();
   if (adapterView != null) {
     return adapterView.getAdapter();
   } else {
     return null;
   }
 }
  /* (non-Javadoc)
   * @see android.widget.AdapterView.OnItemSelectedListener#onItemSelected(android.widget.AdapterView, android.view.View, int, long)
   */
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

    Toast.makeText(
            parent.getContext(),
            "OnItemSelectedListener : " + parent.getItemAtPosition(pos).toString(),
            Toast.LENGTH_SHORT)
        .show();
  }
Exemplo n.º 18
0
 @Override
 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
   Toast.makeText(
           parent.getContext(),
           "Percentage selected is " + parent.getItemAtPosition(pos).toString(),
           Toast.LENGTH_LONG)
       .show();
 }
  public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    /* Get selected FROM and TO address from matching list values */
    if (view == gr_frm_acView) {
      gr_frm_addr = (String) adapterView.getItemAtPosition(position);

    } else if (view == gr_to_acView) {
      gr_to_addr = (String) adapterView.getItemAtPosition(position);
    }
  }
Exemplo n.º 20
0
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   String str =
       parent.getAdapter().getItem(position) == null
           ? null
           : parent.getAdapter().getItem(position).toString();
   if (TextUtils.isEmpty(str)) {
     PhotoUtils.showSelectDialog(mActivity);
   }
 }
Exemplo n.º 21
0
  // WHAT WE SELECTED IN SPINNER
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    // On selecting a spinner item
    item = parent.getItemAtPosition(pos).toString();

    // Showing selected spinner item
    Toast.makeText(parent.getContext(), "Selected: " + item, Toast.LENGTH_SHORT).show();

    // send to database entry
  }
Exemplo n.º 22
0
 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();
  }
Exemplo n.º 24
0
 public void resetItemState(AdapterView<?> parent, int position) {
   int firstVisiblePosition = parent.getFirstVisiblePosition();
   int lastVisiblePosition = parent.getLastVisiblePosition();
   for (int i = firstVisiblePosition; i <= lastVisiblePosition; i++) {
     View view = parent.getChildAt(i - firstVisiblePosition);
     if (view.getTag() instanceof MediaViewHolder) {
       MediaViewHolder holder = (MediaViewHolder) view.getTag();
       setIndex(holder.indexTv, false);
     }
   }
 }
Exemplo n.º 25
0
 @Override
 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
   Spinner spinner = (Spinner) parent;
   if (parent.getId() == R.id.listEncoders) {
     mSelectedEncoder = mEncodersNames[spinner.getSelectedItemPosition()];
     Log.d(TAG, "onItemSelected - encoder: " + mSelectedEncoder);
   } else if (parent.getId() == R.id.listFiles) {
     mSelectedFile = mFilesNames[spinner.getSelectedItemPosition()];
     Log.d(TAG, "onItemSelected - file: " + mSelectedFile);
   }
 }
Exemplo n.º 26
0
 public void updateItemState(AdapterView<?> parent, int position) {
   int firstVisiblePosition = parent.getFirstVisiblePosition();
   int lastVisiblePosition = parent.getLastVisiblePosition();
   if (position >= firstVisiblePosition && position <= lastVisiblePosition) {
     View view = parent.getChildAt(position - firstVisiblePosition);
     if (view.getTag() instanceof MediaViewHolder) {
       MediaViewHolder holder = (MediaViewHolder) view.getTag();
       Media media = getItem(position);
       setIndex(holder.indexTv, contains(media));
     }
   }
 }
Exemplo n.º 27
0
    @SuppressWarnings("unchecked")
    private View generateView(LayoutInflater inflater, ViewGroup container) {
      View layout = inflater.inflate(R.layout.live_wallpaper_list, container, false);

      mAdapter = new LiveWallpaperListAdapter(getActivity());
      AdapterView<BaseAdapter> adapterView =
          (AdapterView<BaseAdapter>) layout.findViewById(android.R.id.list);
      adapterView.setAdapter(mAdapter);
      adapterView.setOnItemClickListener(this);
      adapterView.setEmptyView(layout.findViewById(android.R.id.empty));
      return layout;
    }
Exemplo n.º 28
0
    /**
     * This function is called when an item in the command dropdown is selected. If the Manual
     * command is selected this function opens up a dialog for the user to enter the values to send
     * to the cat. Other wise it sends the command to the cat and updates the command display.
     *
     * @param parent - the AdapterView of the command dropdown.
     * @param view - the View of the spinner widget.
     * @param pos - the position in the array of selectable items that was accepted.
     * @param id - the id of the command dropdown
     */
    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
      String command = parent.getItemAtPosition(pos).toString();

      if (command.equals("Manual")) {
        enterManualCommand();
      } else if (!command.equals("Select Command")) {
        Control.sendCommand(command);
        updateOutput();
      }

      parent.setSelection(0);
    }
Exemplo n.º 29
0
 public int findIndexOfItemContainingText(String targetText) {
   for (int i = 0; i < realAdapterView.getCount(); i++) {
     View childView =
         realAdapterView
             .getAdapter()
             .getView(i, null, new FrameLayout(realAdapterView.getContext()));
     String innerText = shadowOf(childView).innerText();
     if (innerText.contains(targetText)) {
       return i;
     }
   }
   return -1;
 }
Exemplo n.º 30
0
  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;
  }