• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

populate a custom listview with edittext data

 
emerald berazen
Greenhorn
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;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.sample, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.firstLine);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
textView.setText(values[position]);
// Change the icon for Windows and iPhone

return rowView;
}
}

package com.razen.xx;

import android.app.ListActivity;
import android.os.Bundle;

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

}
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic