【发布时间】:2014-06-29 01:47:21
【问题描述】:
我正在尝试运行一个指向 Result.java 的活动,这是我的文件 Tables.java
package com.example.squarecube;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Tables extends Activity{
TextView t1,t2;
EditText e1;
Button b1;
int a,b,ans;
int score,trials;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
trials = 0;
score = 0;
t1 = (TextView) findViewById(R.id.text);
t2 = (TextView) findViewById(R.id.text2);
e1 = (EditText) findViewById(R.id.ans);
b1 = (Button) findViewById(R.id.but);
a= (int)Math.floor(Math.random() * 7) +13;
b= (int)Math.floor(Math.random() * 9) + 1;
t1.setText("What is " + a + "*" + b);
b1.setText("Answer");
t2.setText("Score : "+ score + "\nTrials : " + trials);
b1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0) {
String no = e1.getText().toString();
ans = Integer.parseInt(no);
if (a*b == ans)
{
t1.setText("Correct");
trials++;
score++;
}
else
{
t1.setText("Wrong");
trials++;
}
a= (int)Math.floor(Math.random() * 7) +13;
b= (int)Math.floor(Math.random() * 9) + 1;
t1.setText("What is " + a + "*" + b);
t2.setText("Score : "+ score + "\nTrials : " + trials);
if (trials >= 10)
{
Intent abc = new Intent(Tables.this,Result.class);
Bundle myBun = new Bundle();
myBun.putInt("score", score);
abc.putExtras(myBun);
startActivity(abc);
}
}
});
}
}
这是 android 清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.squarecube"
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="com.example.squarecube.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MainActivity" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.squarecube.Cube"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.Cube" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.squarecube.Tables"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.Tables" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.squarecube.Menu"
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="com.example.squarecube.Result"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.lAUNCHER" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
问题是代码没有切换到Results.java活动,同样的Intent过去对我有用,但我一生都无法理解为什么它没有切换到Results活动
我们将不胜感激您的帮助
【问题讨论】:
-
所有活动都是启动器?
-
我想对所有作为启动器的活动提出同样的问题。
-
那么这个活动叫
Result还是Results? -
是的,除了作为主要活动的菜单
标签: java android android-activity android-manifest