Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

populate a custom listview with edittext data  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package com.razen.xx;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MySimpleArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;

public MySimpleArrayAdapter(Context context, String[] values) {
super(context, R.layout.sample, values);
this.context = context;
this.values = values;
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
View rowView = inflater.inflate(R.layout.sample, parent, false);
TextView textView = (TextView) rowView.findViewById(;
ImageView imageView = (ImageView) rowView.findViewById(;
// Change the icon for Windows and iPhone

return rowView;

package com.razen.xx;

import android.os.Bundle;

public class Xmain extends ListActivity {
public void onCreate(Bundle icicle) {
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, values);

The code above works fine. I need to populate the listview with data from an edittext and a button and remove the constant values. Please help
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!