• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Clicking button lists words

mini139

Newbie
Hi,
I have created a small app. Like by clicking a button the text is viewed. Now i am trying to do is, If my button name is A and by clicking a I want to list of some words stars wit A. Please tell me how to do that.
The following is my code.

[HIGH]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Creating Button variable
Button button = (Button) findViewById(R.id.bt);

//Adding Listener to button
button.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

//Creating TextView Variable
TextView text = (TextView) findViewById(R.id.tv);

//Sets the new text to TextView (runtime click event)
text.setText("Apple");

}

});

}
[/HIGH]
Please help me how to list the words.
 
I have list the words one by one by putting \n. Now i want to do like The button name is APPLE.
By clicking the button the text views like
A-Animal
Arc
P-Pineapple
Peach
P-Pencil
Pen
L-Laptop
Lion
E-Ear
Eat

Like the above it should view the text. Please tell me how to do this.
 
Back
Top Bottom