List of usage examples for android.widget ListView setDividerHeight
public void setDividerHeight(int height)
From source file:com.brookmanholmes.bma.wizard.ui.BaseChoiceFragment.java
protected void setListView(View view) { final ListView listView = (ListView) view.findViewById(android.R.id.list); listView.setTag(page.getClass().getSimpleName()); // used for espresso testing Log.i("BaseChoiceFragment", (String) listView.getTag()); setAdapter();//from ww w. j a v a 2 s . com listView.setDividerHeight(0); listView.setChoiceMode(choiceMode); }
From source file:com.roque.rueda.cashflows.fragments.AccountListFragment.java
/** * Set the listeners for this ListView./*from w ww. ja va 2 s .co m*/ */ private void setListerners() { ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lv.setDivider(getResources().getDrawable(R.color.divider_blue)); lv.setDividerHeight(1); }
From source file:net.ustyugov.jtalk.activity.note.NotesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.notes);//from w w w .j a v a 2s .c om getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); LayoutInflater inflater = LayoutInflater.from(this); MainPageAdapter adapter = new MainPageAdapter(mPages); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View templatePage = inflater.inflate(R.layout.list_activity, null); templatePage.setTag(account); mPages.add(templatePage); ListView list = (ListView) templatePage.findViewById(R.id.list); list.setDividerHeight(1); list.setCacheColorHint(0x00000000); list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final Note note = (Note) parent.getItemAtPosition(position); CharSequence[] items = new CharSequence[2]; items[0] = getString(R.string.Edit); items[1] = getString(R.string.Remove); AlertDialog.Builder builder = new AlertDialog.Builder(NotesActivity.this); builder.setTitle(R.string.Actions); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: createDialog(account, note); break; case 1: try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); nm.removeNote(note); updateNotes(); } catch (Exception ignored) { } break; } } }); builder.create().show(); return true; } }); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }
From source file:net.ustyugov.jtalk.activity.note.TemplatesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.Templates); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); LayoutInflater inflater = LayoutInflater.from(this); MainPageAdapter adapter = new MainPageAdapter(mPages); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst();/*w w w . j a va 2 s . co m*/ do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View templatePage = inflater.inflate(R.layout.list_activity, null); templatePage.setTag(account); mPages.add(templatePage); ListView list = (ListView) templatePage.findViewById(R.id.list); list.setDividerHeight(0); list.setCacheColorHint(0x00000000); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Note item = (Note) parent.getItemAtPosition(position); setResult(RESULT_OK, new Intent().putExtra("text", item.getText())); finish(); } }); list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final Note note = (Note) parent.getItemAtPosition(position); CharSequence[] items = new CharSequence[2]; items[0] = getString(R.string.Edit); items[1] = getString(R.string.Remove); AlertDialog.Builder builder = new AlertDialog.Builder(TemplatesActivity.this); builder.setTitle(R.string.Actions); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: createDialog(account, note); break; case 1: try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); nm.removeNote(note); updateNotes(); } catch (Exception ignored) { } break; } } }); builder.create().show(); return true; } }); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }
From source file:net.ustyugov.jtalk.activity.muc.Bookmarks.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.Bookmarks);/* ww w . j a v a 2s. com*/ getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); LayoutInflater inflater = LayoutInflater.from(this); MainPageAdapter adapter = new MainPageAdapter(mPages); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View bookPage = inflater.inflate(R.layout.list_activity, null); bookPage.setTag(account); mPages.add(bookPage); ListView list = (ListView) bookPage.findViewById(R.id.list); list.setDividerHeight(0); list.setCacheColorHint(0x00000000); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { RosterItem item = (RosterItem) parent.getItemAtPosition(position); BookmarkedConference bc = (BookmarkedConference) item.getObject(); String account = item.getAccount(); String jid = bc.getJid(); String pass = bc.getPassword(); String nick = service.getDerivedNick(service.getConnection(account).getUser(), bc); if (!service.getJoinedConferences().containsKey(jid)) { Toast.makeText(Bookmarks.this, "Attempt joining to " + jid, Toast.LENGTH_SHORT).show(); service.joinRoom(account, jid, nick, pass); } } }); list.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final RosterItem item = (RosterItem) parent.getItemAtPosition(position); CharSequence[] items = new CharSequence[3]; items[0] = getString(R.string.Users); items[1] = getString(R.string.Edit); items[2] = getString(R.string.Remove); AlertDialog.Builder builder = new AlertDialog.Builder(Bookmarks.this); builder.setTitle(R.string.Actions); builder.setItems(items, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: MucDialogs.showUsersDialog(Bookmarks.this, account, (BookmarkedConference) item.getObject()); break; case 1: BookmarksDialogs.EditDialog(Bookmarks.this, account, (BookmarkedConference) item.getObject()); break; case 2: try { BookmarkedConference bc = (BookmarkedConference) item.getObject(); BookmarkManager bm = BookmarkManager .getBookmarkManager(service.getConnection(account)); bm.removeBookmarkedConference(bc.getJid()); } catch (Exception e) { Log.e("Remove", e.getLocalizedMessage()); } updateBookmarks(); break; } } }); builder.create().show(); return true; } }); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }
From source file:eu.trentorise.smartcampus.jp.MyItinerariesFragment.java
@Override public void onStart() { super.onStart(); TextView noitems = (TextView) getView().findViewById(R.id.myitinearies_noitems_label); // if ((myItineraries==null)||(myItineraries.size()==0)) // {/*w w w. java2 s . co m*/ // //put "empty string" // noitems.setVisibility(View.VISIBLE); // } // else { noitems.setVisibility(View.GONE); // } ListView myJourneysList = (ListView) getView().findViewById(R.id.myitineraries_list); adapter = new MyItinerariesListAdapter(getSherlockActivity(), R.layout.itinerarychoicessaved_row, myItineraries); myJourneysList.setAdapter(adapter); myJourneysList.setDivider(null); myJourneysList.setDividerHeight(Utils.convertDpToPixel(6, getActivity())); SCAsyncTask<Void, Void, List<BasicItinerary>> task = new SCAsyncTask<Void, Void, List<BasicItinerary>>( getSherlockActivity(), new GetMyItinerariesProcessor(getSherlockActivity(), adapter)); task.execute(); myJourneysList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager() .beginTransaction(); Fragment fragment = MyItineraryFragment.newInstance(adapter.getItem(position)); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); fragmentTransaction.replace(Config.mainlayout, fragment, Config.MY_JOURNEYS_FRAGMENT_TAG); fragmentTransaction.addToBackStack(fragment.getTag()); fragmentTransaction.commit(); } }); //hide keyboard if it is still open InputMethodManager imm = (InputMethodManager) getSherlockActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getSherlockActivity().getWindow().getDecorView() .findViewById(android.R.id.content).getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY); }
From source file:com.tct.email.activity.setup.EmailPreferenceActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent i = getIntent(); if (savedInstanceState == null) { // If we are not restarting from a previous instance, we need to // figure out the initial prefs to show. (Otherwise, we want to // continue showing whatever the user last selected.) if (INTENT_ACCOUNT_MANAGER_ENTRY == null) { INTENT_ACCOUNT_MANAGER_ENTRY = getString(R.string.intent_account_manager_entry); }// w ww .j ava 2 s. com if (INTENT_ACCOUNT_MANAGER_ENTRY.equals(i.getAction())) { // This case occurs if we're changing account settings from Settings -> Accounts. // We get an account object in the intent, but it's not actually useful to us since // it's always just the first account of that type. The user can't specify which // account they wish to view from within the settings UI, so just dump them at the // main screen. // android.accounts.Account acct = i.getParcelableExtra("account"); } else if (i.hasExtra(EditSettingsExtras.EXTRA_FOLDER)) { throw new IllegalArgumentException("EXTRA_FOLDER is no longer supported"); } else { // Otherwise, we're called from within the Email app and look for our extras final long accountId = IntentUtilities.getAccountIdFromIntent(i); if (accountId != -1) { final Bundle args = AccountSettingsFragment.buildArguments(accountId); startPreferencePanel(AccountSettingsFragment.class.getName(), args, 0, null, null, 0); // TS: jin.dong 2015-08-07 EMAIL BUGFIX_989528 ADD_S finish(); return; // TS: jin.dong 2015-08-07 EMAIL BUGFIX_989528 ADD_E } } } mShowDebugMenu = i.getBooleanExtra(EXTRA_ENABLE_DEBUG, false); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); } ListView listView = getListView(); if (listView != null) { listView.setDivider(new ColorDrawable(Color.GRAY)); listView.setDividerHeight(1); } mFeedbackUri = Utils.getValidUri(getString(R.string.email_feedback_uri)); }
From source file:com.app4am.app4am.LatestNewsListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (savedInstanceState != null) { mPosition = savedInstanceState.getInt(SwipeRefreshFragmentInterface.FRAGMENT_POSITION); }/*w w w . j ava 2s . co m*/ // Change the colors displayed by the SwipeRefreshLayout by providing it with 4 // color resource ids setColorSchemeResources(R.color.color_scheme_1_1, R.color.color_scheme_1_2, R.color.color_scheme_1_3, R.color.color_scheme_1_4); // Set list view background color. view.setBackgroundResource(R.color.color_common_list_background); // List item divider and background color ListView listView = getListView(); listView.setDivider(getResources().getDrawable(R.drawable.common_list_divider)); listView.setDividerHeight((int) getResources().getDimension(R.dimen.common_list_divider_height)); listView.setBackgroundResource(R.color.color_common_list_background); listView.setCacheColorHint(0); // List selector listView.setSelector(R.drawable.list_view_selector); listView.setDrawSelectorOnTop(true); // Event handler listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO: Open topic information page (B01) ?! Log.d(LOG_TAG, "on click"); } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { // TODO: Open topic introduction page (B02) ?! Log.d(LOG_TAG, "on long click"); return false; } }); /** * Create an ArrayAdapter to contain the data for the ListView. Each item in the ListView * uses the system-defined simple_list_item_1 layout that contains one TextView. */ ListAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.latest_news_list_item, R.id.textView, Cheeses.randomList(LIST_ITEM_COUNT)); // Set the adapter between the ListView and its backing data. setListAdapter(adapter); // BEGIN_INCLUDE (setup_refreshlistener) /** * Implement {@link android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener}. When users do the "swipe to * refresh" gesture, SwipeRefreshLayout invokes * {@link android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener#onRefresh onRefresh()}. In * {@link android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener#onRefresh onRefresh()}, call a method that * refreshes the content. Call the same method in response to the Refresh action from the * action bar. */ setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Log.i(LOG_TAG, "onRefresh called from SwipeRefreshLayout"); initiateRefresh(); } }); // END_INCLUDE (setup_refreshlistener) }
From source file:org.jraf.android.hellomundo.app.pickwebcam.PickWebcamListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View res = super.onCreateView(inflater, container, savedInstanceState); // Add 'random' item ListView listView = (ListView) res.findViewById(android.R.id.list); setListAdapter(mAdapter);/* w ww . ja va 2s . c o m*/ mAdapter.setListView(listView); listView.addHeaderView(getHeaderView(listView), null, true); // Disable dividers since they are handled manually in cell layouts listView.setDividerHeight(0); // Disable this optimization because this cause problems on dividers in hdpi listView.setScrollingCacheEnabled(false); // Layout animation listView.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.listview_layout)); return res; }
From source file:qr.cloud.qrpedia.MyTagsListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // configure the list view ListView listView = getListView(); QRCloudUtils.setListViewEmptyView(listView, getString(R.string.no_posted_messages), R.string.default_font, R.dimen.activity_horizontal_margin, R.dimen.activity_vertical_margin); listView.setSelector(R.drawable.message_row_selector); // override the default selector listView.setDivider(new ColorDrawable(this.getResources().getColor(R.color.list_divider))); listView.setDividerHeight(1); if (mIsInDialog && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // fix black background issue pre-honeycomb listView.setBackgroundColor(Color.WHITE); }//from w ww . ja va 2 s . com }