Hi
For several days I have been struggling to put a simple program into effect. That program involves a simple button press now when the user presses this button then I wish to change the text of a text field to reflect that change. What ever way I come about this I am bumping my head dealing with errors.
I have the following in line with the suggestions online I have resorted to a second more slimline program.
Button | Android Developers
WITH
[HIGH]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="30dp"
android:text="My Buttton"
androidnClick="buttonpress"/>
</RelativeLayout>[/HIGH]
And This
[HIGH]public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
TextView display = null;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
display.setText("my text");
}
public void buttonpress (View view){
TextView display;
display=(TextView) findViewById(android.R.id.textView1);
display.setText("I was here");
}[/HIGH]
This now fails a syntax error on the
display=(TextView) findViewById(android.R.id.textView1);
line two lines from the end. any IDEAS!!!!!!
I admit I am completely stumped here on such a simple problem as an adaptation to a classic "Hello World"
For several days I have been struggling to put a simple program into effect. That program involves a simple button press now when the user presses this button then I wish to change the text of a text field to reflect that change. What ever way I come about this I am bumping my head dealing with errors.
I have the following in line with the suggestions online I have resorted to a second more slimline program.
Button | Android Developers
WITH
[HIGH]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="30dp"
android:text="My Buttton"
androidnClick="buttonpress"/>
</RelativeLayout>[/HIGH]
And This
[HIGH]public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
TextView display = null;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
display.setText("my text");
}
public void buttonpress (View view){
TextView display;
display=(TextView) findViewById(android.R.id.textView1);
display.setText("I was here");
}[/HIGH]
This now fails a syntax error on the
display=(TextView) findViewById(android.R.id.textView1);
line two lines from the end. any IDEAS!!!!!!
I admit I am completely stumped here on such a simple problem as an adaptation to a classic "Hello World"