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

The following examples show how to use android.widget.AdapterView#getItemAtPosition() . 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
Source File: ManLocalArchiveFragment.java    From Man-Man with GNU General Public License v3.0 6 votes vote down vote up
@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 2
Source File: FolderFragment.java    From filemanager with 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
Source File: List7.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
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 4
Source File: BaiduNewsListActivity.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: MainActivity.java    From FoldableLayout with 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 6
Source File: ContactListFragment.java    From CSCI4669-Fall15-Android with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: buff_ext.java    From stynico with 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 8
Source File: UserDictionaryAddWordFragment.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: ContactsListFragment.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
@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
Source File: SearchActivity.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: AdapterViewProtocols.java    From android-test with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: TrivialActivity.java    From OPFIab with 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 13
Source File: SearchResultsPage.java    From fanfouapp-opensource with Apache License 2.0 5 votes vote down vote up
@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 14
Source File: AITextSampleActivity.java    From dialogflow-android-client with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    final LanguageConfig selectedLanguage = (LanguageConfig) parent.getItemAtPosition(position);
    initService(selectedLanguage);
}
 
Example 15
Source File: BlurActivity.java    From LiveBlurListView with 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 16
Source File: NavigationPopup.java    From delion with 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 17
Source File: InstallActivity.java    From PMCADemo with 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 18
Source File: StayAwakeTile.java    From GravityBox with 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 19
Source File: CitySelectorActivity.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view,
                        int position, long id) {
    Place p = (Place) adapterView.getItemAtPosition(position);
    doPlace(p);
}
 
Example 20
Source File: AIServiceSampleActivity.java    From dialogflow-android-client with Apache License 2.0 4 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    final LanguageConfig selectedLanguage = (LanguageConfig) parent.getItemAtPosition(position);
    initService(selectedLanguage);
}