Dynamic button

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Dynamic button

Postby ibtmubarak » Fri May 23, 2008 1:37 pm

How to get array of string (gettext) from dynamic button?.. for the following code..
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Cursor f = myDatabase.query(true, "category",null, "status='true'", null, null,
  2.  
  3. null, null);
  4.  
  5. int catename = f.getColumnIndex("categoryname");
  6.  
  7. final int getcount=f.count();
  8.  
  9. if (f != null) {
  10.  
  11. a=0;
  12.  
  13. if (f.first()) {
  14.  
  15. do {
  16.  
  17. categorynames = f.getString(catename);
  18.  
  19.  
  20.  
  21. res[a] = categorynames;
  22.  
  23. a++;
  24.  
  25. } while (f.next());
  26.  
  27. }
  28.  
  29. }
  30.  
  31. for(int c=0;c<getcount;c++)
  32.  
  33. {
  34.  
  35. categorybutton =new Button(FindandInstall.this);
  36.  
  37. categorybutton.setText(res[c]);
  38.  
  39. LinearLayout linearLayout = (LinearLayout) findViewById(R.id.myLinearLayout);
  40.  
  41. linearLayout.setOrientation(LinearLayout.VERTICAL);
  42.  
  43. linearLayout.addView(categorybutton, new LinearLayout.LayoutParams(120,40));
  44.  
  45. categorybutton.setOnClickListener(new Button.OnClickListener() {
  46.  
  47. public void onClick(View view) {
  48.  
  49. if(categorybutton.getText().toString().equals("Dating"))
  50.  
  51. {
  52.  
  53. Intent install = new Intent(FindandInstall.this,
  54.  
  55. Mstuff.class);
  56.  
  57. startActivity(install);
  58.  
  59. }
  60.  
  61. if(categorybutton.getText().toString().equals("Matrimony"))
  62.  
  63. {
  64.  
  65. Intent install = new Intent(FindandInstall.this,
  66.  
  67. Matrimony.class);
  68.  
  69. startActivity(install);
  70.  
  71. }
  72.  
  73. if(categorybutton.getText().toString().equals("Cars"))
  74.  
  75. {
  76.  
  77. Intent install = new Intent(FindandInstall.this,
  78.  
  79. Cars.class);
  80.  
  81. startActivity(install);
  82.  
  83. }
  84.  
  85. }
  86.  
  87. });
  88.  
  89. }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4

the above code.. single dynamic button is added with multiple settext.. if i clicked Dating button.. goto Mstuff class.. if clicked anther button.. goto the same page.... how to get the text from dynamic button in a array of string??? ...
_________________
mubarak
mubarak
ibtmubarak
Developer
Developer
 
Posts: 44
Joined: Thu Feb 28, 2008 12:26 pm
Location: Bangalore

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests