List of usage examples for android.widget AdapterView getItemAtPosition
public Object getItemAtPosition(int position)
From source file:com.chriscartland.octaviastreethilton.ui.MainActivity.java
private void createDrawer() { // Now retrieve the DrawerLayout so that we can set the status bar color. // This only takes effect on Lollipop, or when using translucentStatusBar // on KitKat. DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_main); drawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.color_primary_dark)); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_main); ArrayAdapter drawerAdapter = ArrayAdapter.createFromResource(this, R.array.navigation_array, R.layout.drawer_list_item);// ww w . j a va 2 s . c om mDrawerNavigation = (ListView) findViewById(R.id.drawer_navigation); mDrawerNavigation.setAdapter(drawerAdapter); mDrawerNavigation.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { setTitle(parent.getItemAtPosition(position).toString()); mDrawerLayout.closeDrawer(Gravity.START); } }); setTitle(mDrawerNavigation.getItemAtPosition(0).toString()); }
From source file:com.google.mcommerce.sample.android.chapter09.googleMap.LayersDemoActivity.java
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (!checkReady()) { return;//ww w . ja va2 s. co m } Log.i("LDA", "item selected at position " + position + " with string " + (String) parent.getItemAtPosition(position)); setLayer((String) parent.getItemAtPosition(position)); }
From source file:com.deange.textfaker.ui.activity.ConversationActivity.java
@Override public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, final long id) { final Cursor cursor = (Cursor) parent.getItemAtPosition(position); final Conversation conversation = new Conversation(cursor); showDeleteDialog(conversation.getId(), R.string.dialog_delete_conversation_message); return true;/* w w w . j av a 2s. c o m*/ }
From source file:com.nxt.yn.app.ui.RobotsActivity.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); MyApplication.getInstance().addActivity(this); setContentView(R.layout.em_fragment_robots); findViewById(R.id.layout_title).setBackgroundColor( ZPreferenceUtils.getPrefInt(Constant.SKIN_COLOR, getResources().getColor(R.color.title_color))); inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mListView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); progressBar = findViewById(R.id.progress_bar); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override/*from ww w . j a va2s . c om*/ public void onRefresh() { getRobotNamesFromServer(); } }); Map<String, RobotUser> robotMap = DemoHelper.getInstance().getRobotList(); if (robotMap != null) { robotList.addAll(robotMap.values()); } else { progressBar.setVisibility(View.VISIBLE); getRobotNamesFromServer(); } adapter = new RobotAdapter(this, 1, robotList); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RobotUser user = (RobotUser) parent.getItemAtPosition(position); Intent intent = new Intent(); intent.setClass(RobotsActivity.this, ChatActivity.class); intent.putExtra("userId", user.getUsername()); startActivity(intent); } }); mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Fragments.NodeListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); adapter = new NodeListAdapter(getActivity(), session.getNodeModel().getNodeVector(), session.getSelectedAlgorithm().sourceIsTarget()); setListAdapter(adapter);//from w w w .j av a 2 s .c o m ListView listView = getListView(); registerForContextMenu(listView); if (listView instanceof DragNDropListView) { ((DragNDropListView) listView).setDropListener(mDropListener); ((DragNDropListView) listView).setDragListener(mDragListener); //---------ContextMenu----------------- listView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) contextMenuInfo; contextMenu.setHeaderTitle(adapter.getItem(info.position).getName()); String[] menuItems = { getResources().getString(R.string.edit), getResources().getString(R.string.delete) }; for (int i = 0; i < menuItems.length; i++) { contextMenu.add(Menu.NONE, i, i, menuItems[i]); } } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, final int pos, long arg3) { editNode((Node) adapter.getItemAtPosition(pos), pos); } }); } }
From source file:tv.acfun.video.fragment.SearchFragment.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Object obj = parent.getItemAtPosition(position); if (obj != null && obj instanceof Content) { Content c = (Content) obj;// www .jav a 2 s . c o m DetailsActivity.start(mActivity, c.toVideo()); } }
From source file:com.google.android.demos.atom.app.FeedActivity.java
/** * {@inheritDoc}//from w w w .j ava 2 s. c o m */ public void onItemClick(AdapterView<?> l, View v, int position, long id) { Object item = l.getItemAtPosition(position); Cursor cursor = mAdapter.getCursor(); if (item != null && item == cursor) { showDialog(DIALOG_ENTRY); FeedAdapter.setEntryData(mEntryDialog, cursor); mEntryDialog.scrollToTop(); } }
From source file:com.longshihan.mvpretrofit.activity.im.RobotsActivity.java
@Override protected void initAllMembersView(Bundle savedInstanceState) { inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); ListView mListView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout); if (android.os.Build.VERSION.SDK_INT >= 14) { swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); }/*from w w w. j ava2s .co m*/ progressBar = findViewById(R.id.progress_bar); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { getRobotNamesFromServer(); } }); Map<String, RobotUser> robotMap = DemoHelper.getInstance().getRobotList(); if (robotMap != null) { robotList.addAll(robotMap.values()); } else { progressBar.setVisibility(View.VISIBLE); getRobotNamesFromServer(); } adapter = new RobotAdapter(this, 1, robotList); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RobotUser user = (RobotUser) parent.getItemAtPosition(position); Intent intent = new Intent(); intent.setClass(RobotsActivity.this, ChatActivity.class); intent.putExtra("userId", user.getUsername()); startActivity(intent); } }); mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); }
From source file:com.seraphim.chips.ChipsEditText.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { try {// w ww. ja va2 s. c om ChipEntry entry = (ChipEntry) parent.getItemAtPosition(position); setText(""); mItemClickListener.clicked(entry); } catch (ClassCastException e) { e.printStackTrace(); } }
From source file:ca.ualberta.cmput301.t03.inventory.BrowseInventoryFragment.java
private void setupListView() { adapter = new ItemsAdapter<>(mActivity.getBaseContext(), model); mListview.setAdapter(adapter);/*from ww w. j ava 2s . c om*/ mListview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { inspectItem((Item) parent.getItemAtPosition(position)); } }); mSwipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.browseListSwipeLayout); mSwipeRefreshLayout.setOnRefreshListener(BrowseInventoryFragment.this); }