Eccolo:
public class MainActivity extends AppCompatActivity {
Helper helper;
ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView=(ListView)findViewById(R.id.listView);
/*helper=new Helper(this);
helper.save("Brontolo");
helper.save("Cucciolo");
helper.save("Pisolo");
helper.save("Gongolo");
helper.save("Mammolo");
helper.save("Dotto");
helper.save("Eolo");*/
MyCursorAdapter adapter=new MyCursorAdapter(this,helper.query());
listView.setAdapter(adapter);
LayoutInflater inflater=(LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
View v=inflater.inflate(R.layout.row,null);
EditText editText=(EditText) v.findViewById(R.id.editText);
editText.setText("EXTRA");
listView.addFooterView(v);
}
class MyCursorAdapter extends CursorAdapter{
public MyCursorAdapter(Context context, Cursor c) {
super(context, c);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
LayoutInflater inflater=(LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
return inflater.inflate(R.layout.row,null);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
EditText editText=(EditText) view.findViewById(R.id.editText);
editText.setText(cursor.getString(cursor.getColumnIndex("nome")));
}
}
}
Nessun commento:
Posta un commento