I made simple android ativity consisting of 1 EditText and 1 Button.
The EditText will serve as the output when the Button is pressed.
My expected output is when I press the Button 3 times, in the EditText it should show 3 values but no matter how I press the Button it will only show 1 value. What is wrong with my code? I can't seem to find a solution.
XML code:
JAVA code:
The EditText will serve as the output when the Button is pressed.
My expected output is when I press the Button 3 times, in the EditText it should show 3 values but no matter how I press the Button it will only show 1 value. What is wrong with my code? I can't seem to find a solution.
XML code:
Code:
<Button[INDENT] android:layout_width="45dp"
android:layout_height="45dp"
android:text="@string/button_17"
android:id="@+id/aye"
android:textColor="@color/BLUE"
android:textSize="12dp"
android: onClick="onClickOne"
[/INDENT]/>
Code:
package com.android.example;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class example extends Activity {
private EditText output;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
output = (EditText)findViewById(R.id.output);
}[INDENT] public void onClickOne(View v) {
output.setText(R.string.button_17);
[/INDENT]}
}
)
nClickOne is the click listener.