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 8543625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:21:00+00:00 2026-06-11T12:21:00+00:00

in Android list view can we set some value to each row just like

  • 0

in Android list view can we set some value to each row just like we do in web programming

<td id="123">Display</td>

How can this be done in android.I use the following code for list view display

ArrayList<String> filelist = new ArrayList<String>();
final ListView mainlist   = (ListView)findViewById(R.id.list);
....
....
for (int l=0;l<lines.length;l++)
{
     filelist.addAll( Arrays.asList(lines[l].toString())) ; 
}
ArrayAdapter adp = new ArrayAdapter(this, android.R.layout.simple_list_item_1, filelist);
mainlist.setAdapter(adp);
mainlist.setTextFilterEnabled(true);
  • 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-11T12:21:02+00:00Added an answer on June 11, 2026 at 12:21 pm

    You can try this:

    CustomAdapter.class:

    public class CustomAdapter extends ArrayAdapter<String>{
    
        Context mContext;
        String[] list;
        LayoutInflater mInflater;
        public static HashMap<Integer, Integer> hashkeys=new HashMap<Integer,Integer>();
    
        public CustomAdapter(Context context, int textViewResourceId,
                String[] objects) {
            super(context, textViewResourceId, objects);
            list=objects;
            mInflater = LayoutInflater.from(context);
            mContext=context;
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
             final ViewHolder holder;
    
             if(convertView==null)
             {
                  convertView = mInflater.inflate(R.layout.custom_item, null);
                     holder = new ViewHolder();
    
                     holder.tv=(TextView)convertView.findViewById(R.id.textview);                
                     convertView.setTag(holder);
             }
             else
             {   
                holder=(ViewHolder)convertView.getTag();
             }
             int value=0;
             switch(position){
                 case 0:
                    value=1;
                    break;
                 case 1:
                    value=2; 
                    break;
                 case 3:
                    value=3;
                    break;                  
             }
             hashkeys.put(position,value);         
    
             return convertView;
        }
        static class ViewHolder
        {
                TextView tv;            
        }
    }
    

    Now in your activity,

    CustomAdapter adp = new CustomAdapter(this, R.layout.custom_item, filelist);
    mainlist.setAdapter(adp);
    mainlist.setTextFilterEnabled(true);
    
    mainlist.setOnItemClickListener(new OnItemClickListener() {
    
            @Override
            public void onItemClick(AdapterView<?> arg0, View view, int position,
                            long id) {
    
                String unique_value=CustomAdapter.hashkeys.get(position);//get value on click of item
    
            }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my android app i am using expandable list view to display some text.These
I have noticied that in some android menues, a list view is shown that
I have a ListActivity in Android. Each row is just an item that starts
Can i set setOnItemClickListener if i can't make list view.setonitemcliclistener because mi xml code
For some reason, I can't get text to show up in my list view.
i want to know how to remove underline in display listview in android, can
I want to show a button at the end of an Android list view.
I am using a list view in Android 1.5 to show a list of
I want to implement Paginated list View in android so when I scroll down
I'm building an android application, which has a list view, and in the list

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.