Hello all,
I am trying to get two lines in the same row in a list view and I
looked at some things online but found it hard to apply to what I am
trying to achieve.
Could anyone look at my code please and suggest me how I can make it
possible. Thanks
package com.varun.HelloListView;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
public class HelloListView extends ListActivity {
TextView selection;
ArrayAdapter a1=null;
ArrayAdapter a2=null;
ArrayAdapter a3=null;
ArrayAdapter a4=null;
ArrayAdapter a5=null;
ArrayAdapter a6=null;
ArrayAdapter a7=null;
ArrayAdapter a8=null;
ListActivity myActivity = null;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
a1 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text1,AndroidPhones1);
a2 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text1,AndroidPhones2);
a3 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text1,AndroidPhones3);
a4 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text1,AndroidPhones4);
a5 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text2,line2);
a6 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text2,line2);
a7 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text2,line2);
a8 = new ArrayAdapter(this, R.layout.two_line_list_item,
R.id.text2,line2);
setContentView(R.layout.main);
setListAdapter(a1);
setListAdapter(a5);
myActivity = this;
Button next1 = (Button) findViewById(R.id.Button1);
next1.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view) {
myActivity.setListAdapter(a1);
myActivity.setListAdapter(a5);
a1.notifyDataSetChanged();
a5.notifyDataSetChanged();
}
}
);
//setListAdapter(a2);
//myActivity = this;
Button next2 = (Button) findViewById(R.id.Button2);
next2.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view) {
myActivity.setListAdapter(a2);
a2.notifyDataSetChanged();
}
}
);
//setListAdapter(a3);
//myActivity = this;
Button next3 = (Button) findViewById(R.id.Button3);
next3.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view) {
myActivity.setListAdapter(a3);
a3.notifyDataSetChanged();
}
}
);
//setListAdapter(a4);
//myActivity = this;
Button next4 = (Button) findViewById(R.id.Button4);
next4.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view4) {
myActivity.setListAdapter(a4);
a4.notifyDataSetChanged();
}
}
);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
menu.add(0, Settings.SETTINGS, 0, "Settings");
return true;
}
static final String[] AndroidPhones1 = new String[] {
"HTC Evo 1G", "Google Nexus One", "Motorola Devour",
"Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible", "Samsung Moment", "LG Ally ",
};
static final String[] AndroidPhones2 = new String[] {
"HTC Evo 2G", "Google Nexus One", "Motorola Devour",
"Motorola 2LIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible", "Samsung Moment", "LG Ally ",
};
static final String[] AndroidPhones3 = new String[] {
"HTC Evo 3G", "Google One", "Motorola Devour",
"Motorola 2LIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible", "Samsung Moment", "LG Ally ",
};
static final String[] AndroidPhones4 = new String[] {
"HTC Evo 4G", "Google Nexus hello", "Motorola Devour",
"Motorola 2LIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible", "Samsung Moment", "LG Ally ",
};
static final String[] line2 = new String[] {
"HTC Evo 4G", "Google Nexus hello", "Motorola Devour",
"Motorola 2LIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible", "Samsung Moment", "LG Ally ",
};
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en