Java Code Examples for android.widget.ListView.getItemAtPosition()

The following are Jave code examples for showing how to use getItemAtPosition() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CSipSimple   File: ShortcutWidgetConfigure.java   View Source Code Vote up 6 votes
@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...");
    }
}
 
Example 2
Project: Virtualview-Android   File: ScrollerListActivity.java   View Source Code Vote up 6 votes
@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);
}
 
Example 3
Project: Virtualview-Android   File: ScriptListActivity.java   View Source Code Vote up 6 votes
@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();
    }
}
 
Example 4
Project: orgzly-android   File: FileBrowserFragment.java   View Source Code Vote up 6 votes
@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");
    }
}
 
Example 5
Project: AndroidUiKit   File: HomeActivity.java   View Source Code Vote up 6 votes
@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);
}
 
Example 6
Project: dex-hdog   File: MainActivity.java   View Source Code Vote up 6 votes
@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);
}
 
Example 7
Project: AOSP-Kayboard-7.1.2   File: AccountsSettingsFragment.java   View Source Code Vote up 6 votes
@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;
    }
}
 
Example 8
Project: Virtualview-Android   File: ComponentListActivity.java   View Source Code Vote up 5 votes
@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);
}
 
Example 9
Project: Virtualview-Android   File: TmallComponentListActivity.java   View Source Code Vote up 5 votes
@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);
}
 
Example 10
Project: Virtualview-Android   File: DemoListActivity.java   View Source Code Vote up 5 votes
@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);
    }
}
 
Example 11
Project: orgzly-android   File: DrawerFragment.java   View Source Code Vote up 5 votes
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    if (mListener != null) {
        DrawerItem item = (DrawerItem) l.getItemAtPosition(position);

        mListener.onDrawerItemClicked(item);
    }
}
 
Example 12
Project: Seconds   File: ActivityMain.java   View Source Code Vote up 5 votes
@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);
}
 
Example 13
Project: buildAPKsApps   File: SimplyDoActivity.java   View Source Code Vote up 5 votes
@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");
    }
}
 
Example 14
Project: buildAPKsApps   File: SimplyDoActivity.java   View Source Code Vote up 5 votes
@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);
}
 
Example 15
Project: buildAPKsApps   File: SimplyDoActivity.java   View Source Code Vote up 5 votes
@Override
public void onItemClick(AdapterView<?> adapter, View view, int position,
        long id)
{
    Log.v(L.TAG, "ListsListReactor.onItemClick()");
    
    ListView listView = (ListView)findViewById(R.id.ListsListView);
    ListDesc listDesc = (ListDesc)listView.getItemAtPosition(position);
    listSelected(listDesc, true);
}
 
Example 16
Project: buildAPKsApps   File: SimplyDoActivity.java   View Source Code Vote up 5 votes
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo)
{
    Log.v(L.TAG, "ListsListReactor.onCreateContextMenu()");
    
    AdapterContextMenuInfo ctxMenuInfo = (AdapterContextMenuInfo)menuInfo;
    ListView listView = (ListView)findViewById(R.id.ListsListView);
    ctxList = (ListDesc)listView.getItemAtPosition(ctxMenuInfo.position);

    menu.setHeaderTitle("List Options");
    menu.add(Menu.NONE, EDIT_LIST, Menu.NONE, "Edit");
    menu.add(Menu.NONE, DELETE_LIST, Menu.NONE, "Delete");
}
 
Example 17
Project: AndroidInstantVideo   File: MainActivity.java   View Source Code Vote up 5 votes
@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);
}
 
Example 18
Project: AndroidCollection   File: MainActivity.java   View Source Code Vote up 5 votes
@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);
}
 
Example 19
Project: grafika   File: MainActivity.java   View Source Code Vote up 4 votes
@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);
}
 
Example 20
Project: WiFiView   File: RestoreActivity.java   View Source Code Vote up 4 votes
public void show_menu(int position, int item) throws IOException {
    final ListView lista = (ListView) findViewById(R.id.list1);

    if (item == 0) {

        Toast.makeText(RestoreActivity.this, getString(R.string.csoon), Toast.LENGTH_LONG).show();
    }

    if (item == 1) {

        String items = (String) lista.getItemAtPosition(position);
        String[] item1 = items.split("\n");
        String item2 = item1[0].replace("SSID: ", "");

        File file = new File(Environment.getExternalStorageDirectory() + File.separator
                + getString(R.string.folder_name) + File.separator + item2 + ".txt");
        boolean deleted = file.delete();

        mSwipeRefreshLayout.setRefreshing(true);
        refreshItems();

        Toast.makeText(RestoreActivity.this, getString(R.string.deleted), Toast.LENGTH_LONG).show();
    }

}