Изучаю урок с два и более актикивити, переход на другое активити за счёт кнопки.
Сделала, вроде бы, всё по уроку, но выдал в MainActivity.java ошибку на
Код: Выделить всё
aboutprog.setOnClickListener(this);Код из activity_main.xml
Код: Выделить всё
<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=".MainActivity" >
<Button
android:id="@+id/containerlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/containerlist"
android:layout_alignParentBottom="true"
android:layout_marginBottom="94dp"
android:onClick="containerlist_Click"
android:text="Банк листов" />
<Button
android:id="@+id/creatlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="creatlist_Click"
android:text="Создать лист" />
<Button
android:id="@+id/conticgame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/conticgame"
android:layout_alignLeft="@+id/conticgame"
android:layout_marginBottom="34dp"
android:onClick="conticgame_Click"
android:text="Продолжить" />
<Button
android:id="@+id/aboutprog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:onClick="aboutprog_Click"
android:text="О программе" />
</RelativeLayout>код из mainActivity.java
Код: Выделить всё
package ru.lenwords;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
Button aboutprog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
aboutprog = (Button) findViewById(R.id.aboutprog);
aboutprog.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.aboutprog:
Intent intent = new Intent(this, ActivityAbout.class);
startActivity(intent);
break;
default:
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
код из манифестового файла
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.lenwords"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="ru.lenwords.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ActivityAbout"></activity>
</application>
</manifest>Код: Выделить всё
package ru.lenwords;
import android.app.Activity;
import android.os.Bundle;
public class ActivityAbout extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
}
}
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="184dp"
android:layout_height="216dp"
android:text="lo 2" >
</TextView>
</LinearLayout>Вооот. Помогите разобраться с этим делом. А то проект не запускается. Хм-хм.
