Example usage for android.widget ListView setCacheColorHint

List of usage examples for android.widget ListView setCacheColorHint

Introduction

In this page you can find the example usage for android.widget ListView setCacheColorHint.

Prototype

@Override
    public void setCacheColorHint(int color) 

Source Link

Usage

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);/*from www. j ava  2  s .  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:net.abcdroid.devfest12.ui.SocialStreamFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    view.setBackgroundColor(Color.WHITE);

    final ListView listView = getListView();
    listView.setCacheColorHint(Color.WHITE);
    listView.setOnScrollListener(this);
    listView.setDrawSelectorOnTop(true);
    TypedValue v = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.activatableItemBackground, v, true);
    listView.setSelector(v.resourceId);/*from  w  ww .ja  v  a  2 s .c o m*/
}

From source file:com.WazaBe.GooglePlusStream.SocialStreamFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    view.setBackgroundColor(Color.WHITE);

    final ListView listView = getListView();
    listView.setCacheColorHint(Color.WHITE);
    listView.setOnScrollListener(this);
    listView.setDrawSelectorOnTop(true);
    // TypedValue v = new TypedValue();
    // getActivity().getTheme().resolveAttribute(R.attr.activatableItemBackground,
    // v, true);//from w  w w.  j a  va2  s  .com
    // listView.setSelector(v.resourceId);
}

From source file:com.sft.blackcatapp.EnrollSchoolActivity.java

private void showOpenCityPopupWindow(View parent) {
    if (openCityPopupWindow == null) {
        LinearLayout popWindowLayout = (LinearLayout) View.inflate(mContext, R.layout.pop_window, null);
        popWindowLayout.removeAllViews();
        // LinearLayout popWindowLayout = new LinearLayout(mContext);
        popWindowLayout.setOrientation(LinearLayout.VERTICAL);
        ListView OpenCityListView = new ListView(mContext);
        OpenCityListView.setDividerHeight(0);
        OpenCityListView.setCacheColorHint(android.R.color.transparent);
        OpenCityListView.setOnItemClickListener(new OnItemClickListener() {

            @Override//from  w ww.  j a  v  a  2 s.co  m
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                OpenCityVO selectCity = openCityList.get(position);
                System.out.println(selectCity.getName());
                cityname = selectCity.getName();
                licensetype = "";
                schoolname = "";
                ordertype = "";
                index = 1;
                obtainNearBySchool();
                openCityPopupWindow.dismiss();
                openCityPopupWindow = null;
            }
        });
        LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        popWindowLayout.addView(OpenCityListView, param);
        OpenCityAdapter openCityAdapter = new OpenCityAdapter(mContext, openCityList);
        OpenCityListView.setAdapter(openCityAdapter);

        openCityPopupWindow = new PopupWindow(popWindowLayout, 130, LayoutParams.WRAP_CONTENT);
    }
    openCityPopupWindow.setFocusable(true);
    openCityPopupWindow.setOutsideTouchable(true);
    // Back???
    openCityPopupWindow.setBackgroundDrawable(new BitmapDrawable());

    openCityPopupWindow.showAsDropDown(parent);
}

From source file:org.openremote.android.console.AppSettingsActivity.java

/**
 * Auto discovery servers and add them in a list view.
 * Click a list item and make it as current server.
 * //from w  ww.  j a v a2s .co  m
 * @return the list view
 */
private ListView constructAutoServersView() {
    final ListView lv = new ListView(this);
    lv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200));
    lv.setPadding(20, 5, 5, 10);
    lv.setBackgroundColor(0);
    lv.setCacheColorHint(0);
    lv.setItemsCanFocus(true);
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(),
            R.layout.server_list_item, new ArrayList<String>());
    lv.setAdapter(serverListAdapter);

    new IPAutoDiscoveryServer() {
        @Override
        protected void onProgressUpdate(Void... values) {
            if (progressLayout != null) {
                progressLayout.setVisibility(View.VISIBLE);
            }
        }

        @Override
        protected void onPostExecute(List<String> result) {
            int length = result.size();
            for (int i = 0; i < length; i++) {
                serverListAdapter.add(result.get(i));
            }
            if (length > 0) {
                lv.setItemChecked(0, true);
                currentServer = serverListAdapter.getItem(0);
                AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer);
            }
            if (progressLayout != null) {
                progressLayout.setVisibility(View.INVISIBLE);
            }
            requestPanelList();
            checkAuthentication();
            requestAccess();
        }
    }.execute((Void) null);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            currentServer = (String) parent.getItemAtPosition(position);
            AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer);
            requestPanelList();
            checkAuthentication();
            requestAccess();
        }
    });

    return lv;
}

From source file:org.solovyev.android.messenger.BaseListFragment.java

protected void fillListView(@Nonnull ListView lv, @Nonnull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        lv.setScrollbarFadingEnabled(true);
    }//from   w  w  w .j ava  2s  . c  o m
    lv.setBackgroundDrawable(null);
    lv.setCacheColorHint(Color.TRANSPARENT);
    ListViewScroller.createAndAttach(lv, this);
    lv.setFastScrollEnabled(true);

    lv.setTextFilterEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        lv.setOverscrollFooter(null);
    }

    lv.setVerticalFadingEdgeEnabled(false);
    lv.setFocusable(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    }
    lv.setDivider(new ColorDrawable(Color.LTGRAY));
    lv.setDividerHeight(1);
}

From source file:com.eleybourn.bookcatalogue.utils.Utils.java

/**
 * Call setCacheColorHint on a listview and trap IndexOutOfBoundsException. 
 * //from  w  ww.  j  a v  a2  s  .  c  om
 * There is a bug in Android 2.2-2.3 (approx) that causes this call to throw 
 * exceptions *sometimes* (circumstances unclear):
 * 
 *     http://code.google.com/p/android/issues/detail?id=9775
 * 
 * Ideally this code should use reflection to set it, or check android versions.
 * 
 * @param lv      ListView to set
 * @param hint      Colour hint
 */
public static void setCacheColorHintSafely(ListView lv, int hint) {
    try {
        lv.setCacheColorHint(hint);
    } catch (IndexOutOfBoundsException e) {
        // Ignore
        System.out.println("Android Bug avoided");
    }
}

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);
    }/* w w  w.  j  ava 2 s  .c o 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);

    // 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)

}