How can a have a ListView that has different amount of rows? Instead of being fixe开发者_C百科d to the array size. I’m loading in information from a html file to a array called Linknames. I then use I then creat a array adapter to link my LinkName array to my ListView. The problem, when I load data into ListView it could be from 1 to 10 colums. So I set my ListVies as anm array with 10 elemtsd. Now my ListView is always 10 elements.
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // data read in can be from 1-10
    images=new String[10];
    Links=new String[10];
    LinkName=new String[10];
    Price=new String[10];   
Loaddata();     
setListAdapter(new IconicAdapter(this));
} // end function
class IconicAdapter extends ArrayAdapter {
    Activity context;
    IconicAdapter(Activity context) {
        super(context, R.layout.row, LinkName);
        this.context=context;
    }
    public View getView(int position, View convertView,
                                            ViewGroup parent) {
        LayoutInflater inflater=context.getLayoutInflater();
        View row=inflater.inflate(R.layout.row, null);
        TextView label=(TextView)row.findViewById(R.id.label);
        label.setText( LinkName[position] );
        return(row);
    }
}   
Use an ArrayList instead of a Java array.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论