當前位置: 首頁>>代碼示例>>Java>>正文


Java ListView.getItemAtPosition方法代碼示例

本文整理匯總了Java中android.widget.ListView.getItemAtPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.getItemAtPosition方法的具體用法?Java ListView.getItemAtPosition怎麽用?Java ListView.getItemAtPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.getItemAtPosition方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);

    Integer index = (Integer) map.get(KEY_INDEX);

    if(appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
        SharedPreferences prefs = getSharedPreferences(WIDGET_PREFS, 0);
        SharedPreferences.Editor edit = prefs.edit();
        edit.putInt(getPrefsKey(appWidgetId), index);
        edit.commit();
        
        
        Intent resultValue = new Intent();
        resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        appWidgetId);
        setResult(RESULT_OK, resultValue);
        
        ShortcutWidgetProvider.updateWidget(this);
        
        finish();
    }else {
        Log.w(THIS_FILE, "Invalid widget ID here...");
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:27,代碼來源:ShortcutWidgetConfigure.java

示例2: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, String> item = (Map<String, String>)l.getItemAtPosition(position);
    String className = item.get("class");
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(this, className));
    intent.putExtra("name", item.get("name"));
    intent.putExtra("data", item.get("data"));
    startActivity(intent);
}
 
開發者ID:alibaba,項目名稱:Virtualview-Android,代碼行數:11,代碼來源:ScrollerListActivity.java

示例3: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, String> item = (Map<String, String>)l.getItemAtPosition(position);
    String className = item.get("class");
    if (className != null) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(this, className));
        intent.putExtra("name", item.get("name"));
        intent.putExtra("data", item.get("data"));
        startActivity(intent);
    } else {
        String result = VSEngine.test();
        Toast.makeText(getApplicationContext(), "executing result: " + result, Toast.LENGTH_LONG).show();
    }
}
 
開發者ID:alibaba,項目名稱:Virtualview-Android,代碼行數:16,代碼來源:ScriptListActivity.java

示例4: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    Item item = (Item) l.getItemAtPosition(position);

    if (mCurrentItem != null) {
        if (item.isUp) {
            File path = new File(mCurrentItem);

            if (path.getParentFile() != null) {
                mNextItem = path.getParentFile().getAbsolutePath();
                tryLoadFileListFromNext(false);
            }

        } else {
            File sel = new File(mCurrentItem, item.name);

            if (sel.isDirectory()) {
                mNextItem = sel.getAbsolutePath();
                tryLoadFileListFromNext(false);
            }
        }

    } else {
        Log.e(TAG, "Clicked on " + item.name + " but there is no current directory set");
    }
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:27,代碼來源:FileBrowserFragment.java

示例5: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);

    Intent intent = new Intent((Intent) map.get("intent"));
    intent.addCategory(APP_CAGEGORY);
    startActivity(intent);
}
 
開發者ID:yangjiantao,項目名稱:AndroidUiKit,代碼行數:10,代碼來源:HomeActivity.java

示例6: onItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    ListView listView = (ListView) parent;
    AppInfo appInfo = (AppInfo) listView.getItemAtPosition(position);
    String packageName = appInfo.getPackageName();
    String appName = appInfo.getAppName();
    Log.d(TAG, packageName);
    if(!JniUtil.isRunning(packageName)){
        openApp(packageName);
    }

    Log.d(TAG, "Create folder:" + FileUtil.createPath(HDOG_PATH +File.separator + packageName + File.separator + TYPE_DEX));
    Log.d(TAG, "Create folder:" + FileUtil.createPath(HDOG_PATH +File.separator + packageName + File.separator + TYPE_DEY));

    Intent intent = new Intent(this, DumpActivity.class);
    intent.putExtra("package_name", packageName);
    intent.putExtra("app_name", appName);
    startActivity(intent);
}
 
開發者ID:gnaixx,項目名稱:dex-hdog,代碼行數:20,代碼來源:MainActivity.java

示例7: onClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onClick(final DialogInterface dialog, final int which) {
    final String oldAccount = getSignedInAccountName();
    switch (which) {
        case DialogInterface.BUTTON_POSITIVE: // Signed in
            final ListView lv = ((AlertDialog)dialog).getListView();
            final String newAccount =
                    (String) lv.getItemAtPosition(lv.getCheckedItemPosition());
            getSharedPreferences()
                    .edit()
                    .putString(PREF_ACCOUNT_NAME, newAccount)
                    .apply();
            AccountStateChangedListener.onAccountSignedIn(oldAccount, newAccount);
            if (mDependentPreference != null) {
                mDependentPreference.setChecked(true);
            }
            break;
        case DialogInterface.BUTTON_NEUTRAL: // Signed out
            AccountStateChangedListener.onAccountSignedOut(oldAccount);
            getSharedPreferences()
                    .edit()
                    .remove(PREF_ACCOUNT_NAME)
                    .apply();
            break;
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:27,代碼來源:AccountsSettingsFragment.java

示例8: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, String> item = (Map<String, String>)l.getItemAtPosition(position);
    String className = item.get("class");
    if (className != null) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(this, className));
        startActivity(intent);
    }
}
 
開發者ID:alibaba,項目名稱:Virtualview-Android,代碼行數:11,代碼來源:DemoListActivity.java

示例9: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    if (mListener != null) {
        DrawerItem item = (DrawerItem) l.getItemAtPosition(position);

        mListener.onDrawerItemClicked(item);
    }
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:9,代碼來源:DrawerFragment.java

示例10: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);

    Intent intent = (Intent) map.get("intent");
    startActivity(intent);
}
 
開發者ID:yangyankai,項目名稱:Seconds,代碼行數:9,代碼來源:ActivityMain.java

示例11: onCreateContextMenu

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo)
{
    Log.v(L.TAG, "ItemsListReactor.onCreateContextMenu()");
    
    AdapterContextMenuInfo ctxMenuInfo = (AdapterContextMenuInfo)menuInfo;
    ListView listView = (ListView)findViewById(R.id.ItemsListView);
    ctxItem = (ItemDesc)listView.getItemAtPosition(ctxMenuInfo.position);

    menu.setHeaderTitle("Item Options");
    menu.add(Menu.NONE, EDIT_ITEM, Menu.NONE, "Edit");
    menu.add(Menu.NONE, DELETE_ITEM, Menu.NONE, "Delete");
    String toggleText;
    if(ctxItem.isStar())
    {
        toggleText = "Remove Star";
    }
    else
    {
        toggleText = "Add Star";
    }
    menu.add(Menu.NONE, TOGGLE_STAR, Menu.NONE, toggleText);
    if(dataViewer.getListData().size() > 1)
    {
        menu.add(Menu.NONE, MOVE_ITEM, Menu.NONE, "Move To");
    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:29,代碼來源:SimplyDoActivity.java

示例12: onItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> adapter, View view, int position,
        long id)
{
    Log.v(L.TAG, "ItemsListReactor.onItemClick()");
    
    ListView listView = (ListView)findViewById(R.id.ItemsListView);
    ItemDesc itemDesc = (ItemDesc)listView.getItemAtPosition(position);
    itemSelected(itemDesc);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:11,代碼來源:SimplyDoActivity.java

示例13: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);

    Intent intent = (Intent) map.get("intent");
    startActivity(intent);
}
 
開發者ID:ChillingVan,項目名稱:AndroidInstantVideo,代碼行數:9,代碼來源:MainActivity.java

示例14: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);

    Intent intent = new Intent((Intent) map.get("intent"));
    intent.addCategory(Intent.CATEGORY_SAMPLE_CODE);
    startActivity(intent);
}
 
開發者ID:zhuangzaiku,項目名稱:AndroidCollection,代碼行數:9,代碼來源:MainActivity.java

示例15: onListItemClick

import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onListItemClick(ListView listView, View view, int position, long id) {
    Map<String, Object> map = (Map<String, Object>)listView.getItemAtPosition(position);
    Intent intent = (Intent) map.get(CLASS_NAME);
    startActivity(intent);
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:7,代碼來源:MainActivity.java


注:本文中的android.widget.ListView.getItemAtPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。