Java Code Examples for android.widget.AdapterView#getItemAtPosition()

The following examples show how to use android.widget.AdapterView#getItemAtPosition() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
    if (position >= 0) {
        //Get current cursor
        Cursor c = (Cursor) parent.getItemAtPosition(position);
        int type = c.getInt(COLUMN_PHONE_TYPE);
        String phone = c.getString(COLUMN_PHONE_NUMBER);
        String label = null;
        //Custom type? Then get the custom label
        if (type == Phone.TYPE_CUSTOM) {
            label = c.getString(COLUMN_PHONE_LABEL);
        }
        //Get the readable string
        String numberType = (String) Phone.getTypeLabel(getResources(), type, label);
        String text = numberType + ": " + phone;
        mPhone.setText(text);
    }
}
 
Example 2
Source Project: filemanager   File: FolderFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View arg1, int position, long arg3)
{
	Object selectedObject = adapterView.getItemAtPosition(position);
	if (selectedObject instanceof File)
	{
		if (actionMode == null)
		{
			File selectedFile = (File) selectedObject;
			if (selectedFile.isDirectory())
				navigateTo(selectedFile);
			else 
				openFile(selectedFile);
		}
		else
		{
			toggleFileSelected((File) selectedObject);
		}			
	}
}
 
Example 3
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    mSearchLocalPage.clearFocus(); // otherwise we have to click "back" twice

    File data = (File) parent.getItemAtPosition(position);
    if(data == null) { // header is present, start config tool
        switch (position) {
            case 0: // Watch folders
                showFolderSettingsDialog();
                break;
            case 1: // Download archive
                downloadArchive();
                break;
        }
    } else {
        ManPageDialogFragment mpdf = ManPageDialogFragment.newInstance(data.getName(), data.getPath());
        getFragmentManager()
                .beginTransaction()
                .addToBackStack("PageFromLocalArchive")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .replace(R.id.replacer, mpdf)
                .commit();
    }
}
 
Example 4
@Override
public boolean onItemLongClick(final AdapterView<?> parent,
        final View view, final int position, final long id) {
    final Status s = (Status) parent.getItemAtPosition(position);
    showPopup(view, s);
    return true;
}
 
Example 5
@Override
protected void realOnItemClick(AdapterView<?> parent, View view, int position, long id)
{
	News news = (News) parent.getItemAtPosition(position);
	Intent intent = new Intent();
	intent.setClass(this, BaiduNewsDetailActivity.class);
	intent.putExtra("news_title", news.getTitle());
	intent.putExtra("news_url", news.getUrl());

	startActivity(intent);
}
 
Example 6
Source Project: OPFIab   File: TrivialActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int position,
                           final long id) {
    final Helper helper = (Helper) parent.getItemAtPosition(position);
    if (helper != TrivialBilling.getHelper()) {
        TrivialBilling.setHelper(helper);
        startActivity(new Intent(TrivialActivity.this, LauncherActivity.class));
        finish();
    }
}
 
Example 7
@Override
public Iterable<AdaptedData> getDataInAdapterView(AdapterView<? extends Adapter> adapterView) {
  List<AdaptedData> datas = Lists.newArrayList();
  for (int i = 0; i < adapterView.getCount(); i++) {
    int position = i;
    Object dataAtPosition = adapterView.getItemAtPosition(position);
    datas.add(
        new AdaptedData.Builder()
            .withDataFunction(new StandardDataFunction(dataAtPosition, position))
            .withOpaqueToken(position)
            .build());
  }
  return datas;
}
 
Example 8
@Override
protected void realOnItemClick(AdapterView<?> parent, View view, int position, long id)
{
	AlbumInfo albumInfo = (AlbumInfo) parent.getItemAtPosition(position);
	Intent intent = new Intent(getContext(), ImageGridActivity.class);
	intent.putExtra(RockyIntent.EXTRA_ALBUM, albumInfo);
	startActivity(intent);
}
 
Example 9
@Override
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
	LinphoneContact contact = (LinphoneContact) adapter.getItemAtPosition(position);
	if (editOnClick) {
		editConsumed = true;
		LinphoneActivity.instance().editContact(contact, sipAddressToAdd);
	} else {
		lastKnownPosition = contactsList.getFirstVisiblePosition();
		LinphoneActivity.instance().displayContact(contact, onlyDisplayChatAddress);
	}
}
 
Example 10
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int pos,
        final long id) {
    final LocaleRenderer locale = (LocaleRenderer)parent.getItemAtPosition(pos);
    if (locale.isMoreLanguages()) {
        PreferenceActivity preferenceActivity = (PreferenceActivity)getActivity();
        preferenceActivity.startPreferenceFragment(new UserDictionaryLocalePicker(), true);
    } else {
        mContents.updateLocale(locale.getLocaleString());
    }
}
 
Example 11
Source Project: stynico   File: buff_ext.java    License: MIT License 5 votes vote down vote up
@Override
   public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id)
   {
AppInfo app = (AppInfo) parent.getItemAtPosition(position);
Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
String pkg = "com.android.settings";
String cls = "com.android.settings.applications.InstalledAppDetails";
intent.setComponent(new ComponentName(pkg, cls));
intent.setData(Uri.parse("package:" + app.packageName));//指明要打开的应用
startActivity(intent);// 用普通的方法去打开界面
return true;// 消化掉事件
   }
 
Example 12
@Override
public void onItemClick(AdapterView<?> parent, View view,
   int position, long id) 
{
    Contact c = (Contact) parent.getItemAtPosition(position);
   listener.onContactSelected(c.id); // pass selection to MainActivity
}
 
Example 13
Source Project: FoldableLayout   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    ActivityInfo info = (ActivityInfo) parent.getItemAtPosition(position);
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(this, info.name));
    startActivity(intent);
}
 
Example 14
@Override
public void onItemClick(AdapterView<?> adapterView, View view,
                        int position, long id) {
    Place p = (Place) adapterView.getItemAtPosition(position);
    doPlace(p);
}
 
Example 15
Source Project: PMCADemo   File: InstallActivity.java    License: MIT License 4 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    SpkListItem item = (SpkListItem) adapterView.getItemAtPosition(position);
    installPackage(item.getFile());
}
 
Example 16
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    final LanguageConfig selectedLanguage = (LanguageConfig) parent.getItemAtPosition(position);
    initService(selectedLanguage);
}
 
Example 17
Source Project: LiveBlurListView   File: BlurActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
	// TODO Auto-generated method stub
	AppInfo mAppInfo = (AppInfo)arg0.getItemAtPosition(arg2);
	launch_app(mAppInfo);
}
 
Example 18
Source Project: delion   File: NavigationPopup.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    NavigationEntry entry = (NavigationEntry) parent.getItemAtPosition(position);
    mNavigationController.goToNavigationIndex(entry.getIndex());
    dismiss();
}
 
Example 19
Source Project: GravityBox   File: StayAwakeTile.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    ScreenTimeout st = (ScreenTimeout) parent.getItemAtPosition(position);
    setScreenOffTimeout(st.mMillis);
}
 
Example 20
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    final LanguageConfig selectedLanguage = (LanguageConfig) parent.getItemAtPosition(position);
    initService(selectedLanguage);
}