This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Android and the fly likes listview with checkbox problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "listview with checkbox problem" Watch "listview with checkbox problem" New topic

listview with checkbox problem

ghouse mohammed

Joined: Nov 23, 2011
Posts: 15
hi i am creating a listview with checkbox. if i define data in class itself it is working but i want to access the data from string.xml file and i am using the following code. please suggest me solution how to access it
public class ListTestActivity extends ListActivity {
/** Called when the activity is first created. */
String tag = "Events";
String[] presidents;
public void onCreate(Bundle savedInstanceState) {
// Create an array of Strings, that will be put to our ListActivity
presidents =getResources().getStringArray(R.array.presidents_array);
ArrayAdapter<Model> adapter = new InteractiveArrayAdapter(this,
Log.d(tag," event");

private List<Model> getModel() {
List<Model> list = new ArrayList<Model>();

list.add(get("Linux"));/// here i want to access the strings.xml file instead of this any suggestion
// Initially select one of the items
Log.d(tag," event1");
return list;

private Model get(String s) {
Log.d(tag," event2");
return new Model(s);
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Solution is very simple....

To retrieve String from string.xml you can use getText(R.string.<your string resource name>);

getText is method defined in Context class.

I hope I understood you question correctly.
ghouse mohammed

Joined: Nov 23, 2011
Posts: 15
hi Hardik Trivedi thanks for the replay and problem is solved . i have another doubt i am creating a custom listview with two checkboxes with a array adapter class with the following code i want to retrieve the checkbox name which i have selected how it can be done blow is the code i am using will you suggest me what i am doing wrong

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

Would you please edit your posts and use "Code" tags to format your code? It is really hard to follow your code without formatting.
ghouse mohammed

Joined: Nov 23, 2011
Posts: 15
hi as said earlier in my post i have a custom listview with a textview and two checkboxes in a single row how could i knoe which checkbox is checked please let me know.
and when i checked one box after i scrolldown and again see that both the checkboxes are being checked what i am doing wrong
I agree. Here's the link:
subject: listview with checkbox problem
It's not a secret anymore!