问题描述
解决方案
解决方案二:
mainactivity.javapackagecom.example.seagame;importandroid.support.v7.app.ActionBarActivity;importandroid.support.v4.app.Fragment;importandroid.content.Intent;importandroid.os.Bundle;importandroid.view.LayoutInflater;importandroid.view.Menu;importandroid.view.MenuItem;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.view.ViewGroup;importandroid.view.Window;importandroid.view.WindowManager;importandroid.widget.Button;publicclassMainActivityextendsActionBarActivity{/***Aplaceholderfragmentcontainingasimpleview.*/publicstaticclassPlaceholderFragmentextendsFragment{publicPlaceholderFragment(){}@OverridepublicViewonCreateView(LayoutInflaterinflater,ViewGroupcontainer,BundlesavedInstanceState){ViewrootView=inflater.inflate(R.layout.fragment_main,container,false);returnrootView;}}@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);Buttonbutton3=(Button)findViewById(R.id.about_button);button3.setOnClickListener(newButtonListener());requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题setContentView(R.layout.activity_main);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏if(savedInstanceState==null){getSupportFragmentManager().beginTransaction().add(R.id.container,newPlaceholderFragment()).commit();}//publicvoidonClick(Viewv){//switch(v.getId()){//caseR.id.aboutbutton;//Intenti=newIntent(this,About.class);//startActivity(i);//break;////Morebuttonsgohere(ifany)...//}//}}classButtonListenerimplementsOnClickListener{@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstubIntentintent=newIntent();intent.setClass(MainActivity.this,AboutActivity.class);MainActivity.this.startActivity(intent);}}@OverridepublicbooleanonCreateOptionsMenu(Menumenu){//Inflatethemenu;thisaddsitemstotheactionbarifitispresent.getMenuInflater().inflate(R.menu.main,menu);returntrue;}@OverridepublicbooleanonOptionsItemSelected(MenuItemitem){//Handleactionbaritemclickshere.Theactionbarwill//automaticallyhandleclicksontheHome/Upbutton,solong//asyouspecifyaparentactivityinAndroidManifest.xml.intid=item.getItemId();if(id==R.id.action_settings){returntrue;}returnsuper.onOptionsItemSelected(item);}}
解决方案三:
manifest<?xmlversion="1.0"encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.example.seagame"android:versionCode="1"android:versionName="1.0"><uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="19"/><applicationandroid:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme"><activityandroid:name="com.example.seagame.MainActivity"android:label="@string/app_name"android:launchMode="singleTask"android:screenOrientation="landscape"><intent-filter><actionandroid:name="android.intent.action.MAIN"/><categoryandroid:name="android.intent.category.LAUNCHER"/></intent-filter></activity><activityandroid:name="com.example.seagame.AboutActivity"android:label="@string/title_activity_about"></activity></application></manifest>
解决方案四:
fragmentmain<RelativeLayoutxmlns: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.seagame.MainActivity$PlaceholderFragment"><Buttonandroid:id="@+id/exit_button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignLeft="@+id/about_button"android:layout_below="@+id/about_button"android:text="@string/exitgame"/><Buttonandroid:id="@+id/about_button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignLeft="@+id/score_button"android:layout_below="@+id/score_button"android:text="@string/aboutgame"/><Buttonandroid:id="@+id/start_button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignLeft="@+id/score_button"android:layout_alignParentTop="true"android:layout_marginTop="23dp"android:text="@string/startgame"/><Buttonandroid:id="@+id/score_button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/start_button"android:layout_centerHorizontal="true"android:text="@string/scoregame"/></RelativeLayout>
解决方案五:
android:layout_below="@+id/about_button"
改成如下:android:layout_below="@id/put_word"
+1在@后面使用“+”,表示当修改完某个布局文件并保存后,系统会自动在R.java文件中生成相应的int类型变量。变量名就是“/”后面的值@后面没有+的就是直接引用这个ID
解决方案六:
引用4楼qq695181966的回复:
android:layout_below="@+id/about_button"改成如下:android:layout_below="@id/put_word"
+1在@后面使用“+”,表示当修改完某个布局文件并保存后,系统会自动在R.java文件中生成相应的int类型变量。变量名就是“/”后面的值@后面没有+的就是直接引用这个ID
不行啊。。