ListView
Androidでビルドしたい。multiple coloums
可能性を秘めているはずchange color of only some rows
です。私はこれを試しましたが、LinearLayout のtoString()を呼び出していると思います。私は取得しませんtext inside the TextView
。私は数日で試しました。助けてください。以下のコードは、実際のプロジェクトの単なる実験です。
public class EventActivity extends ListActivity {
List<Event> events2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.event_layout);
ListView listView = (ListView) findViewById(R.id.listEvents);
listView = getListView();
TextView t1 = new TextView(getBaseContext());
TextView t2 = new TextView(getBaseContext());
TextView t3 = new TextView(getBaseContext());
TextView t4 = new TextView(getBaseContext());
TextView t5 = new TextView(getBaseContext());
TextView t6 = new TextView(getBaseContext());
TextView t7 = new TextView(getBaseContext());
t1.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
t2.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
t3.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
t4.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
t5.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
t6.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
t1.setText("1111");
t2.setText("2111");
t3.setText("3111");
t4.setText("4111");
t5.setText("5111");
t6.setText("6111");
t7.setText("7111");
t1.setBackgroundColor(Color.GREEN);
t4.setBackgroundColor(Color.GREEN);
LinearLayout ll = new LinearLayout(this);
ll.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(t1);
ll.addView(t2);
ll.addView(t3);
ll.addView(t4);
ll.addView(t5);
ll.addView(t6);
ll.addView(t7);
ArrayList<LinearLayout> lllist = new ArrayList<LinearLayout>();
lllist.add(ll);
ArrayAdapter<LinearLayout> eventAdapter = new ArrayAdapter<LinearLayout>(EventActivity.this,
android.R.layout.simple_list_item_1,lllist );
listView.setAdapter(eventAdapter);