How can I change the background color for an specific row properly in a ListView? (Android)

前端 未结 7 1982
别那么骄傲
别那么骄傲 2020-12-17 05:05

I have spent some days trying to solve a problem I have with ListViews on Android. I would like to implement a single selection list box using a ListView. So, I would like t

相关标签:
7条回答
  • 2020-12-17 05:43
        @Override
        public View getView(int position, View convertView, ViewGroup parent) 
        {
       LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
      View itemView = inflater.inflate(R.layout.verselayout, parent, false); 
        txttitle = (TextView) itemView.findViewById(R.id.Versetxt);
        if (position%2 == 0) {
           txttitle.setTextColor(Color.parseColor("#FFFFFF"));
        }
     else
           {
        txttitle.setTextColor(Color.parseColor("#FFFF00"));
           }
    
         return itemView;
        }
    
    0 讨论(0)
提交回复
热议问题