The following is my Exam. Java code:
Import the Java. Security. The Key;
The import android. App. The Activity;
The import android. Content. Intent;
import android.os.Bundle;
The import android. View. The Menu;
The import android. View. MenuItem;
import android.view.View;
import android.widget.Button;
The import android. Widget. The EditText;
Public class Exam extends the Activity {
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Try {
The setContentView (R.l ayout. Exam);
} the finally {
}
The final Button Button=(Button) the findViewById (R.i db utton1);
Final EditText first=(EditText) the findViewById (R.i d.e dit1);
Final EditText second=(EditText) the findViewById (R.i d.e dit2);
Final EditText third=(EditText) the findViewById (R.i d.e dit3);
Button. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
Bundle bun=new Bundle ();
Bun. PutCharSequence (" one ", first. The getText (), toString ());
Bun. PutCharSequence (" two ", the second. The getText (), toString ());
Bun. PutCharSequence (" three ", third getText (), toString ());
Intent login=new Intent (Exam. This, the Key. Class);
The login. PutExtras (bun);
StartActivity (login);
}
});
}
@ Override
Public Boolean onCreateOptionsMenu (Menu Menu) {
//to Inflate the menu; This adds the items to the action bar if it is present.
GetMenuInflater (). Inflate (R.m emu. Main, menu).
return true;
}
@ Override
Public Boolean onOptionsItemSelected (MenuItem item) {
//Handle The action bar item on here. The action bar will
//automatically handle on on the Home/the Up button, so long
//as you specify a parent activity in AndroidManifest. XML.
Int id=item. GetItemId ();
If (id==da ction_settings R.i) {
return true;
}
Return super. OnOptionsItemSelected (item);
}
}
CodePudding user response:
Write clearly, you didn't write 117 lines of XML has a control "layout_width" attributeCodePudding user response:
Want to see the log, the error has been very clearYou must supply a layout_width attribute
Layout file or a specific layout controls no configuration layout_width or configuration errors
CodePudding user response:
Ok, I will change it, but can't realize the page transformation is how to return a responsibility?
The following is my mainfest. XML code:
<? The XML version="1.0" encoding="utf-8"?>
Android: versionCode="1"
Android: versionName="1.0" & gt;
Android: targetSdkVersion="19"/& gt;
The android: icon="@ drawable/ic_launcher"
Android: label="@ string/app_name"
Android: theme="@ style/AppTheme" & gt;
Android: label="@ string/app_name" & gt;
Android: label="@ string/app_name" & gt;
Android: targetPackage="com. Njupt. Junit1" & gt;
CodePudding user response:
I look at your code, your intent. PutExtra (bun). This without the keyCodePudding user response:
Please note that the import your own name for the Key class, rather than the Key class system
CodePudding user response:
Intent login=new Intent (Exam. This, the Key. Class);The Key is you want to start the Activity? The package name is wrong, another Activity needs in AndroidManifest. XML fame,
CodePudding user response:
Hey, why don't you buy a book to see,,CodePudding user response:
The forehead (even though it's o... This mistake beginners can understand that the first thing you see an error message, you need to look to their translation feedback error refers to a specific place what do you mean to the error message again to modify, are generally can solve the problemCodePudding user response:
Thank you for your help, just suddenly found that I write the wrong another activity id, correct can run now, be careful next time