我已经动态创建了文本框...现在我想知道如何获取每个文本框的 id ..通过他们的 id 我想获取数据并将其显示到另一种形式...如果可能的话请帮我..
public class remaind_report extends Activity {
SQLiteDatabase db;
LinearLayout l2;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.remaind_report);
db = openOrCreateDatabase("tracker.db",
SQLiteDatabase.CREATE_IF_NECESSARY, null);
Toast.makeText(getApplicationContext(), "Database Is Created
Successfully...", Toast.LENGTH_LONG).show();
l2 = (LinearLayout)findViewById(R.id.layout_remind);
db= SQLiteDatabase.openDatabase("sdcard/tracker.db",null,SQLiteDatabase.CREATE_IF_NECESSARY);
try
{
db.execSQL("CREATE TABLE remind(renotes VARCHAR(200),date
TEXT,time TEXT);");
Toast.makeText(getApplicationContext(), "Table Is Created
Successfully....", Toast.LENGTH_LONG).show();
}
catch(Exception ex)
{
Toast.makeText(getApplicationContext(), "Table Is Already
Exists.....", Toast.LENGTH_LONG).show();
}
try {
Cursor c1 = db.rawQuery("select * from remind ",null);
int theTotal= c1.getCount();
Toast.makeText(this, "Total: "+ theTotal, 1).show();
String[] args= {"renotes","date","time"};
int notesCol= c1.getColumnIndex("renotes");
int dateCol= c1.getColumnIndex("date");
int timeCol = c1.getColumnIndex("time");
TextView t1=null;
while(c1.moveToNext()) {
t1=new TextView(getApplicationContext());
t1.setText("textbox");
t1.setId(notesCol);
t1.setClickable(true);
t1.setBackgroundColor(Color.parseColor("#ff009999"));
l2.addView(t1);
args[0] = c1.getString(notesCol);
args[1] = c1.getString(dateCol);
args[2] = c1.getString(timeCol);
t1.append("\nNotes: "+ args[0]+"\nDate: "+args[1]+"\nTime: "+args[2]+"\n");
t1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
{
Toast.makeText(getApplicationContext(),"hiiii...",
Toast.LENGTH_LONG).show();
// do stuf here
}
}
});
}
}
catch (Exception e){
Toast.makeText(getApplicationContext(),e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
}