以下是我的Exam.java的代码:
import java.security.Key;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;public class Exam extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.exam);
} finally {
} final Button button = (Button) findViewById(R.id.button1);
final EditText first = (EditText) findViewById(R.id.edit1);
final EditText second = (EditText) findViewById(R.id.edit2);
final EditText third = (EditText) findViewById(R.id.edit3); button.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
Bundle bun = new Bundle();
bun.putCharSequence("one", first.getText().toString());
bun.putCharSequence("two", second.getText().toString());
bun.putCharSequence("three", third.getText().toString());
Intent login = new Intent(Exam.this, Key.class);
login.putExtras(bun);
startActivity(login);
}
}); } @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;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}}
解决方案 »
- 关于android4.0以上版本连接webseivice时。报空指针获取不到数据问题。大家都有什么心得,或者大家都是怎么处理的?
- android webservice调用wsdl
- Android 连接网络问题
- 关于tcc8900启动问题
- android 虚拟机运行错误 有谁知道是什么原因
- SurfaceFlinger里面一个算法类,不知道什么作用。
- 关于安卓的问题
- 请问微信、阿里旺旺这类IM对大数据是怎么进行传输的
- java.lang.NoSuchMethodError。
- 为什么FindViewById不用new一个对象就能直接赋值给某个引用变量?
- 请问,安卓系统在开发3D应用和游戏方面用什么引擎做开发?
- Android Studio中NDK开发C/C++代码无语法提示,无法debug或标红的问题。
you must supply a layout_width attribute
layout文件中某个布局或者控件没有配置layout_width或者配置错误
好的,我改过来了,可是没办法实现页面的转化是怎么回事呢
下面是我的mainfest.xml代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sy6_1"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="android.test.runner" />
<activity
android:name=".Exam"
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=".Key"
android:label="@string/app_name" >
</activity>
</application>
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.njupt.junit1" ></instrumentation>
</manifest>
请注意import你自己名字为Key的类,而不是系统的Key类
其中的Key是你要启动的Activity么?包名错了。另外Activity需要在AndroidManifest.xml中声名。