Dynamic GridView items in Android

后端 未结 1 520
故里飘歌
故里飘歌 2021-02-06 19:41

Hey i\'m trying to build an app in which the user can input some numbers and these numbers will be shown in a gridview with custom grid view items. If i use the common gridview

1条回答
  •  一整个雨季
    2021-02-06 20:24

    Try this,

    public View getView(int position, View convertView, ViewGroup parent) {         
        View v;         
    
        if(convertView == null) {
            LayoutInflater li = getLayoutInflater();
            v = li.inflate(R.layout.grid_item, null);
        } else {             
            v = convertView;         
        }
    
        TextView tv = (TextView)v.findViewById(R.id.grid_item_text);
        tv.setText(items.get(position));         
    
        return v;     
    } 
    

    0 讨论(0)
提交回复
热议问题