0

I want to create an listview that shows 5 rows at a time. It should have middle row visible with bigger text than the other rows. The 2nd and 4th rows visible but with text smaller than middle row and the 1st and 5th visible with smaller text again. So listview looks like a wheel running..

Listview comes up with lots of list values.

I tried but cant achieve an effect similar to this:

enter image description here

Chilledrat
  • 2,593
  • 3
  • 28
  • 38
Mind Android
  • 558
  • 2
  • 9
  • 27

3 Answers3

0

try this.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub


        convertView = layoutInflator.inflate(R.layout.customlistview_xml,
                null);
        TextView head = (TextView) convertView.findViewById(R.id.header);



        if (position % 2 == 0) {
            // you can vary these and check..
            head.setTextSize(float value);

        } if(position % 3 == 0) {
            head.setTextSize(float value);

        }
      else {
       head.setTextSize( normal float value);
       }

        Itemclass attach = new Itemclass();
        attach = structure.get(position);

        head.setText(attach.name);

         }
          return convertView;
Invader
  • 679
  • 3
  • 10
  • like this http://stackoverflow.com/questions/19834446/android-custom-wheel-or-slot-machine-implementation – Mind Android Nov 21 '13 at 10:00
  • THanx.. but this does not work.. if 2nd item gets bigger and As i scroll every time this 2nd item will have bigger size even if it is on visible position with smaller text size. – Mind Android Nov 21 '13 at 10:11
0

use Customized list view for this... and in getView method set the size of text.

for example..

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

View = convertView;
 view = layoutInflator.inflate(R.layout.listrow,null);
TextView tv =(TextView) view.findViewById(R.id.tv);

if(position==0){
   tv.setTextSize(your text size here);

 }
 tv.setText("text");

return view; 

}

Naveed Ali
  • 2,609
  • 1
  • 22
  • 37
  • THanx.. but this does not work.. if 0th item gets bigger and As i scroll every time this 0th item will have bigger size even if it is on visible position with smaller text size. – Mind Android Nov 21 '13 at 10:12
0

As you want to make difference in every row depending on your condition you have to first catch the position of row you are getting in list item. After that you have to put in that list item your desire layout design or data.

If you want you can also change the layout design component from code as you are just trying to increase the size of textview. So at first get the position of list item by :

getItemViewType(int position) - returns information which layout type you should use based on position

After that just increase the size of your texview by : tvYourTextView.setSize("Your text size");

Check for details : HowTo: ListView, Adapter, getView and different list items’ layouts in one ListView

Happy coding!!!

Siddiq Abu Bakkar
  • 1,949
  • 1
  • 13
  • 24