In a new Java application I'm developing, a button that I created doesn't seem to work... The error message I get is : "button3 cannot be resolved or is not a field".
Here is all the code:
package com.example.trueorfalsetest;
import com.example.trueorfalsetest.R;
import android.support.v7.app.ActionBarActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity123_456 extends ActionBarActivity implements OnClickListener {
@SuppressWarnings("unused")
private TextView mTextView;
private Button mButton3;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity123_456);
mButton3 = (Button) findViewById(R.id.button3);
mButton3.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId())
{
case R.id.button3:
showThreeButtonDialog();
break;
}
}
private void showThreeButtonDialog()
{
Intent myIntent = new Intent(MainActivity123_456.this, MainActivity123.class);
MainActivity123_456.this.startActivity(myIntent);
}
}
and
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">True or False Test</string>
<string name="textView1">5 x 3 = 15</string>
<string name="Button1">True</string>
<string name="Button2">False</string>
<string name="title_activity_main_activity123_4">True or False Test</string>
<string name="textView2">This application is running on an iPhone.</string>
<string name="title_activity_main_activity123_45">True or False Test</string>
<string name="textView3">The capital of Canada is Ottawa.</string>
<string name="title_activity_main_activity123_456">MainActivity123_456</string>
<string name="textView4">Congratulations! You won! Thank you for playing!</string>
<string name="Button3">Back to the First Question</string>
</resources>
and finally
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.trueorfalsetest.MainActivity123_456" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/textView4"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="@string/Button3" />
</RelativeLayout>
Thank you in advance!
0 comments:
Post a Comment