Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8856655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:24:15+00:00 2026-06-14T14:24:15+00:00

Possible Duplicate: how to change selected list item background, android In android tablets in

  • 0

Possible Duplicate:
how to change selected list item background, android

In android tablets in the settings screen, the background of the listitem from the list changes until user makes the next selection, Which is standard way of getting that feature to work. Till now i used a boolean for the item which is selected and i was refreshing the list to reflect the changes after each click, i dont this, this is the right approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:24:16+00:00Added an answer on June 14, 2026 at 2:24 pm
    You can use the following process . It works fine.
    
       Write a Global bean that get the postion of the selected item from the list.
    
         public class Global {      
            public static int mListPosition = 0; 
    
            public static int getListPosition() {
                    return mListPosition;
                }    
            public static void setListPosition(int mListPosition) {
                    Global.mListPosition = mListPosition;
                }   
    
            }
    
    from List onClickListener set the position into the global bean
    
    
    mList.setOnItemClickListener(new OnItemClickListener() {
    
                public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                        long arg3) {
                    Global.setListPosition(arg2);
    mAdapter.notifyDataSetChanged();
    }
            });
    
    
    
    in the adapter 
    
        @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater) mCtx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.details_retailer_list_row, null);
    
                    mHolder = new ViewHolder();
                    v.setTag(mHolder);
    
                    mHolder.mDetailsRetailerLayout = (LinearLayout) v.findViewById(R.id.details_cart_retailer_row_layout);
                    mHolder.mDetailsRetailer = (TextView) v.findViewById(R.id.detailsRetailerRow);
    
                }
                else {
                    mHolder =  (ViewHolder) v.getTag();
                }           
    
    
                final CartDetailsRetailerBean mDetailsRetailerBean = mItems.get(position);
                if (position == Global.getListPosition()) {
                    mHolder.mDetailsRetailerLayout
                            .setBackgroundResource(R.drawable.row_white);
                } else {
                    mHolder.mDetailsRetailerLayout
                            .setBackgroundResource(R.drawable.row_red);
                }
    
                if(mDetailsRetailerBean != null){
    
                    Log.i("Global Position", ""+Global.getListPosition());
    
    
    
                    mHolder.mDetailsRetailer.setText(mDetailsRetailerBean.getRetailerName());
    
                }
    
                return v;
            }
    
            class ViewHolder {
                public LinearLayout mDetailsRetailerLayout;
                public TextView mDetailsRetailer;
    
            }
    
    
    Please apply it . I think it will work fine.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can you animate a height change on a UITableViewCell when selected? This
Possible Duplicate: change layout and template in zend dynamically according to the device(android tab,iphone,ipad)
Possible Duplicate: How to change appearance of URL from within a PHP script I
Possible Duplicate: ToggleButton state change programmatically rather than automatically in Android? I am trying
Possible Duplicate: Flip-Animation for Activity-Change I'm new to Android Animation . I wanted to
Possible Duplicate: Why does the background of TextView change it's size? I have a
Possible Duplicate: how to change the font on the text view in android? I
Possible Duplicate: How to change database settings for a deployed war file? OK I
Possible Duplicate: Use jquery to change second select list based on first select list
Possible Duplicate: Change language programatically in Android I would like to develop an Android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.