Using java Syntax Highlighting
- Cursor f = myDatabase.query(true, "category",null, "status='true'", null, null,
- null, null);
- int catename = f.getColumnIndex("categoryname");
- final int getcount=f.count();
- if (f != null) {
- a=0;
- if (f.first()) {
- do {
- categorynames = f.getString(catename);
- res[a] = categorynames;
- a++;
- } while (f.next());
- }
- }
- for(int c=0;c<getcount;c++)
- {
- categorybutton =new Button(FindandInstall.this);
- categorybutton.setText(res[c]);
- LinearLayout linearLayout = (LinearLayout) findViewById(R.id.myLinearLayout);
- linearLayout.setOrientation(LinearLayout.VERTICAL);
- linearLayout.addView(categorybutton, new LinearLayout.LayoutParams(120,40));
- categorybutton.setOnClickListener(new Button.OnClickListener() {
- public void onClick(View view) {
- if(categorybutton.getText().toString().equals("Dating"))
- {
- Intent install = new Intent(FindandInstall.this,
- Mstuff.class);
- startActivity(install);
- }
- if(categorybutton.getText().toString().equals("Matrimony"))
- {
- Intent install = new Intent(FindandInstall.this,
- Matrimony.class);
- startActivity(install);
- }
- if(categorybutton.getText().toString().equals("Cars"))
- {
- Intent install = new Intent(FindandInstall.this,
- Cars.class);
- startActivity(install);
- }
- }
- });
- }
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


