List of usage examples for android.widget ListView setDrawSelectorOnTop
public void setDrawSelectorOnTop(boolean onTop)
From source file:com.app4am.app4am.MainTopicListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (savedInstanceState != null) { mPosition = savedInstanceState.getInt(SwipeRefreshFragmentInterface.FRAGMENT_POSITION); }//from w ww . j a v a 2 s. com // 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); // Attach topic banner. The banner is dynamically loaded from the server. // TODO: Real image source url. ListView listView = getListView(); listView.addHeaderView(mHeaderView); ImageView imageViewTopicBanner = (ImageView) mHeaderView.findViewById(R.id.iv_topic_banner); int cornerRadiusInPx = getResources() .getDimensionPixelSize(R.dimen.topic_list_item_background_corner_radius); DisplayImageOptions options = new DisplayImageOptions.Builder() .displayer(new RoundedBitmapDisplayer(cornerRadiusInPx)) //rounded corner bitmap .cacheInMemory(true).build(); ImageLoader imageLoader = ImageLoader.getInstance(); imageLoader.displayImage("assets://todo_topic_banner_1.png", imageViewTopicBanner, options); // List item divider and background color 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) { // Open topic introduction page (B02). onOpenTopicIntroduction(); return true; } }); /** * 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.topic_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:com.hichinaschool.flashcards.anki.CardEditor.java
private StyledDialog createDialogIntentInformation(Builder builder, Resources res) { builder.setTitle(res.getString(R.string.intent_add_saved_information)); ListView listView = new ListView(this); mIntentInformationAdapter = new SimpleAdapter(this, mIntentInformation, R.layout.card_item, new String[] { "source", "target", "id" }, new int[] { R.id.card_sfld, R.id.card_tmpl, R.id.card_item }); listView.setAdapter(mIntentInformationAdapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override/* w w w .jav a2 s . c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(CardEditor.this, CardEditor.class); intent.putExtra(EXTRA_CALLER, CALLER_CARDEDITOR_INTENT_ADD); HashMap<String, String> map = mIntentInformation.get(position); intent.putExtra(EXTRA_CONTENTS, map.get("fields")); intent.putExtra(EXTRA_ID, map.get("id")); startActivityForResult(intent, REQUEST_INTENT_ADD); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(CardEditor.this, ActivityTransitionAnimation.FADE); } mIntentInformationDialog.dismiss(); } }); mCardItemBackground = Themes.getCardBrowserBackground()[0]; mIntentInformationAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { if (view.getId() == R.id.card_item) { view.setBackgroundResource(mCardItemBackground); return true; } return false; } }); listView.setBackgroundColor(android.R.attr.colorBackground); listView.setDrawSelectorOnTop(true); listView.setFastScrollEnabled(true); Themes.setContentStyle(listView, Themes.CALLER_CARDEDITOR_INTENTDIALOG); builder.setView(listView, false, true); builder.setCancelable(true); builder.setPositiveButton(res.getString(R.string.intent_add_clear_all), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { MetaDB.resetIntentInformation(CardEditor.this); mIntentInformation.clear(); dialog.dismiss(); } }); StyledDialog dialog = builder.create(); mIntentInformationDialog = dialog; return dialog; }