简体   繁体   中英

How to display ArrayList data in tabular format in android

I have a problem in display data in to respective fields.

I have like this data from database in arraylist.

 ArrayList<String> ar= new ArrayList<String>;

ar data is:-> [2, India#1, USA#3, Australia#1, Germany#2];

How to get above data like this arraylist:

 Country ArrayList: India,USA,Australai, Gernamy
 valucheck arraylist: 1,3,1,2

Here first element is id and others ara values. Like India- EditText field and integer(1,2,3) is radiobutton.

 India         1(checked first radio button)
 India         3(checked third radio button)
 Australia     1(Checked first radio button)
 Germany       2(Checked second radio button)

I have been trying lots of time, but could get proper solution, so please update some tricks for display those data I want to display like this data in to tabular form

What i did,

 List<EditText> listET = new ArrayList<EditText>();
 ArrayList<String> first= new ArrayList<String>();
if(edittextfield){
first.add("India");first.add("USA");first.add("Australia");first.add("Germany");

      EditText et_text_input = new EditText(getContext());
         for(int p=0;p<listET.size()+1;p++){
                    et_text_input.setText(first.get(p));
                    listET.add(et_text_input);
                    ll.addView(et_text_input);
                    }
  }else if(radiobuttonfield){
 what to do in radiobutton.
 }

Here If i put data in list of first in static, then works fine, but how to put about ar list data into first list ..

看一下ListView -class。

查看ArrayAdapter( http://developer.android.com/reference/android/widget/ArrayAdapter.html ),它可让您在ListView中显示数据。

Assuming you mean output to console, you could step through the list and display it's items with tab separation

//As an example of usage, not a solution using your structures
for (MyObject o : ar)
{
  System.out.println(o.getCountry() + "\t" + o.getValue())
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM