1

I'm using one from the built-in list item layout in my app.

I want to change the style of this list like text color or size of text .

I'm using simple_list_item_1 from these items .

Can you help me how I can do that.

0

3 Answers 3

1
You should make a custom Layout and inflate it in getView() method of Adapter.


 public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = getLayoutInflater();
        View row;
        row = inflater.inflate(R.layout.custom, parent, false);
        TextView title, detail;
        ImageView i1;
        title = (TextView) row.findViewById(R.id.title);
        detail = (TextView) row.findViewById(R.id.detail);
        i1=(ImageView)row.findViewById(R.id.img);
        title.setText(Title[position]);
        detail.setText(Detail[position]);
        i1.setImageResource(imge[position]);

        return (row);
    }

you can look into this thing more on Custom Listview

and from my personal opinion you can use RecyclerView for better Customisation.

0

Do you mean in the Android Studio preview?

If so, tools:listitem="@layout/list-item-layout" is your friend.

-1

Create your own layout and place it in your app layout directory and refer that in your code instead of simple_list_item_1

Example here

R.layout.<yourLayoutName>

instead of

android.R.layout.simple_list_item_1

And customize the layout as you like it!!

2
  • so I can't customize the built-in list item , this is my question ! Dec 3, 2015 at 12:18
  • you can't ...because its builtin, but you can copy and place it elsewhere and manipulate it to meet your requirements
    – johnrao07
    Dec 3, 2015 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.