List of usage examples for android.widget ListView setItemsCanFocus
public void setItemsCanFocus(boolean itemsCanFocus)
From source file:nl.sogeti.android.gpstracker.viewer.TrackList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.tracklist); Toolbar toolbar = (Toolbar) findViewById(R.id.support_actionbar); setSupportActionBar(toolbar);//from ww w .jav a 2 s. co m getSupportActionBar().setDisplayHomeAsUpEnabled(true); displayIntent(getIntent()); ListView listView = getListView(); listView.setItemsCanFocus(true); // Add the context menu (the long press thing) registerForContextMenu(listView); if (savedInstanceState != null) { setSelection(savedInstanceState.getInt("POSITION")); } }
From source file:com.csipsimple.ui.calllog.CallLogListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // View management mDualPane = getResources().getBoolean(R.bool.use_dual_panes); // Modify list view ListView lv = getListView(); lv.setVerticalFadingEdgeEnabled(true); // lv.setCacheColorHint(android.R.color.transparent); if (mDualPane) { lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lv.setItemsCanFocus(false); } else {// w w w . ja v a 2 s . co m lv.setChoiceMode(ListView.CHOICE_MODE_NONE); lv.setItemsCanFocus(true); } // Map long press lv.setLongClickable(true); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) { turnOnActionMode(); getListView().setItemChecked(pos, true); mMode.invalidate(); return true; } }); }
From source file:com.conferenceengineer.android.iosched.ui.ScheduleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_empty_container, container, false);//w w w .j ava2s . c o m inflater.inflate(R.layout.empty_waiting_for_sync, (ViewGroup) root.findViewById(android.R.id.empty), true); root.setBackgroundColor(Color.WHITE); ListView listView = (ListView) root.findViewById(android.R.id.list); listView.setItemsCanFocus(true); listView.setCacheColorHint(Color.WHITE); listView.setSelector(android.R.color.transparent); return root; }
From source file:monakhv.android.samlib.AuthorTagsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { helper = new SettingsHelper(this); setTheme(helper.getTheme());//from w w w .ja v a 2 s. co m super.onCreate(savedInstanceState); setContentView(R.layout.author_tags); author_id = getIntent().getExtras().getInt(AuthorTagsActivity.AUTHOR_ID); ListView listView = getListView(); String[] from = { SQLController.COL_TAG_NAME }; int[] to = { android.R.id.text1 }; Cursor attributesCursor = getCursor(); adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, attributesCursor, from, to, 0); listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listView.setItemsCanFocus(false); loadTagData(); registerForContextMenu(listView); }
From source file:de.electricdynamite.pasty.ClipboardFragment.java
@Override public void onLoadFinished(Loader<PastyLoader.PastyResponse> loader, PastyLoader.PastyResponse response) { ProgressBar pbLoading = (ProgressBar) getSherlockActivity().findViewById(R.id.progressbar_downloading); pbLoading.setVisibility(View.GONE); pbLoading = null;/*w w w. j av a 2 s .c o m*/ mHelpTextBig.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); mHelpTextBig.setBackgroundDrawable(mBackground); if (response.isFinal) { getSherlockActivity().setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); if (response.getResultSource() == PastyResponse.SOURCE_CACHE) { Toast.makeText(getSherlockActivity().getApplicationContext(), getString(R.string.warning_no_network_short), Toast.LENGTH_SHORT).show(); } } if (response.hasException) { if (LOCAL_LOG) Log.v(TAG, "onLoadFinished(): Loader delivered exception; calling handleException()"); // an error occured getSherlockActivity().setSupportProgressBarIndeterminateVisibility(Boolean.FALSE); PastyException mException = response.getException(); handleException(mException); } else { switch (loader.getId()) { case PastyLoader.TASK_CLIPBOARD_FETCH: JSONArray Clipboard = response.getClipboard(); mItems.clear(); mAdapter.notifyDataSetChanged(); getListView().invalidateViews(); try { if (Clipboard.length() == 0) { //Clipboard is empty mHelpTextBig.setText(R.string.helptext_PastyActivity_clipboard_empty); mHelpTextSmall.setText(R.string.helptext_PastyActivity_how_to_add); } else { for (int i = 0; i < Clipboard.length(); i++) { JSONObject Item = Clipboard.getJSONObject(i); ClipboardItem cbItem = new ClipboardItem(Item.getString("_id"), Item.getString("item")); this.mItems.add(cbItem); } mHelpTextBig.setText(R.string.helptext_PastyActivity_copy); mHelpTextSmall.setText(R.string.helptext_PastyActivity_options); //Assign adapter to ListView ListView listView = (ListView) getSherlockActivity().findViewById(R.id.listItems); listView.setAdapter(mAdapter); listView.setItemsCanFocus(false); listView.setOnItemClickListener(new OnItemClickListener() { @SuppressLint("NewApi") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ClipboardItem Item = mItems.get(position); // get a ClipboardItem from the clicked position if (Item.isLinkified() && prefs.getClickableLinks()) { /* If the clicked item was originally linkified and prefs.getClickableLinks() is true, we manually * fire an ACTION_VIEW intent to simulate Linkify() behavior */ String url = Item.getText(); if (!URLUtil.isValidUrl(url)) url = "http://" + url; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } else { /* Else we copy the item to the systems clipboard, * show a Toast and finish() the activity */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { android.content.ClipboardManager sysClipboard = (android.content.ClipboardManager) getSherlockActivity() .getSystemService(Context.CLIPBOARD_SERVICE); Item.copyToClipboard(sysClipboard); sysClipboard = null; } else { ClipboardManager sysClipboard = (ClipboardManager) getSherlockActivity() .getSystemService(Context.CLIPBOARD_SERVICE); Item.copyToClipboard(sysClipboard); sysClipboard = null; } Toast.makeText(getSherlockActivity().getApplicationContext(), getString(R.string.item_copied), Toast.LENGTH_LONG).show(); getSherlockActivity().finish(); } } }); registerForContextMenu(listView); } } catch (Exception e) { e.printStackTrace(); } break; default: break; } } }
From source file:com.snapshotshopper.SnapshotShopper.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_snapshot_shopper); ListView ShoppingListView = (ListView) findViewById(R.id.ShoppingList); //************************************************************************************************** //Modified from following source: //Source: http://stackoverflow.com/questions/454075enteredText.;4/add-dynamically-elements-to-a-listview-android //Author: Shardul //Author's profile page: http://stackoverflow.com/users/514553/shardul listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, ShoppingListItems);//www. ja v a2s .c o m ShoppingListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); ShoppingListView.setItemsCanFocus(false); ShoppingListView.setAdapter(listAdapter); //************************************************************************************************** //Modified from following source: //Source: http://stackoverflow.com/questions/6205808/how-to-handle-long-tap-on-listview-item //Author: Aleadam //Author's profile page: http://stackoverflow.com/users/542701/aleadam ShoppingListView.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { String dummy = "edit item entry here"; takePicture(view, dummy); return false; } }); //************************************************************************************************** //************************************************************************************************** }
From source file:org.kontalk.ui.ConversationListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mQueryHandler = new ThreadListQueryHandler(getActivity().getContentResolver()); mListAdapter = new ConversationListAdapter(getActivity(), null, getListView()); mListAdapter.setOnContentChangedListener(mContentChangedListener); ListView list = getListView(); // Check to see if we have a frame in which to embed the details // fragment directly in the containing UI. View detailsFrame = getActivity().findViewById(R.id.fragment_compose_message); mDualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE; if (mDualPane) { // TODO restore state list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setItemsCanFocus(true); }/*from w ww. j a v a 2 s .c o m*/ setListAdapter(mListAdapter); setMultiChoiceModeListener(this); }
From source file:roommateapp.info.droid.ActivityBuilding.java
/** * createListViewFreeRooms creates a custom list view * for the current available rooms.//from w ww. j av a2s . c om */ private void createListViewFreeRooms() { String day = (String) ((TextView) pages.get(0).findViewById(R.id.txt_date)).getText(); day = DateHelper.translateWeekday(day, this); ArrayAdapterFreeRoomsItem adapter = new ArrayAdapterFreeRoomsItem(this, R.layout.filerow_free_rooms, FilterHelper.getRoomsTimeFilter(allRooms, this.lectureIndex, day, this.selectedBuilding, this), this); ListView listView = (ListView) pages.get(0).findViewById(R.id.listfreerooms); listView.setAdapter(adapter); listView.setItemsCanFocus(true); }
From source file:roommateapp.info.droid.ActivityBuilding.java
/** * createListViewAll creates a custom list view for * all the entire room list view.//from w w w . j a v a2 s . com * * @param listViewItems */ private void createListViewAll() { // Filter wanted rooms which are going to be displayed this.allRooms = FilterHelper.getRoomsStateFilter(selectedBuilding, filterActive, Preferences.getSize(getApplicationContext())); // Tab: all_rooms ArrayAdapterAllRoomsItem adapter = new ArrayAdapterAllRoomsItem(this, R.layout.filerow_all_rooms, allRooms, this); ListView listView = (ListView) pages.get(1).findViewById(R.id.listAllRooms); listView.setAdapter(adapter); listView.setItemsCanFocus(true); // Display filter statusbar. if (Preferences.isFilterActive(getApplicationContext())) { showFilterStatusbar(getString(R.string.filter_active) + " (" + allRooms.size() + "/" + selectedBuilding.getRoomListKeySet().size() + ")"); } else { hideFilterStatusbar(); } }
From source file:net.primeranks.fs_viewer.fs_replay.EntryPointActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.entry_point); ListView listView = getListView(); listView.setOnItemClickListener(this); // Add a back to top button on the bottom - Create the item backToTop_footer = (Button) getLayoutInflater().inflate(R.layout.user_footer, null); backToTop_footer.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(android.R.drawable.ic_menu_upload), null, null, null); backToTop_footer.setVisibility(View.INVISIBLE); // While empty do not show it headerUser = getLayoutInflater().inflate(R.layout.user_header, null); listView.addFooterView(backToTop_footer, null, true); // Add it to the bottom listView.addHeaderView(headerUser, null, false); userList = new ArrayList<User>(); // Start with an empty one this.userAdapter = new UserAdapter(this, userList); listView.setAdapter(this.userAdapter); listView.setItemsCanFocus(false); connectionReceiver = new ConnectionChangedBroadcastReceiver(); registerReceiver(connectionReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }