我已经创建了一个带有匹配的xml名称的layout和layout-land文件夹,依此类推.但它似乎没有采用布局版本.我没有onConfig()函数或任何其他所以我想知道是否有人可以帮助???
mainpage.xml layout-land
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="vertical" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:background="@color/main_background" androID:gravity="center" androID:padding="30dip"> <TextVIEw androID:ID="@+ID/main_Title_text" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/main_Title" androID:textcolor="@color/text" androID:textSize="25sp" /> <tableLayout androID:ID="@+ID/tablelayout1" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="center" androID:stretchColumns="*"> <tableRow androID:layout_height="wrap_content" androID:layout_wIDth="fill_parent"> <button androID:ID="@+ID/start_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/start_button" androID:textcolor="@color/text" /> <button androID:ID="@+ID/help_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/help_button" androID:textcolor="@color/text" /> </tableRow> <tableRow androID:layout_height="wrap_content" androID:layout_wIDth="match_parent"> <button androID:ID="@+ID/extra_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/extra_button" androID:textcolor="@color/text" /> <button androID:ID="@+ID/stop_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/stop_button" androID:textcolor="@color/text" /> </tableRow> </tableLayout></linearLayout>
布局
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="vertical" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:background="@color/main_background" androID:gravity="center" androID:padding="30dip"> <TextVIEw androID:ID="@+ID/main_Title_text" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/main_Title" androID:textcolor="@color/text" androID:textSize="25sp" /> <button androID:ID="@+ID/start_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/start_button" androID:textcolor="@color/text" /> <button androID:ID="@+ID/help_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/help_button" androID:textcolor="@color/text" /> <button androID:ID="@+ID/extra_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/extra_button" androID:textcolor="@color/text" /> <button androID:ID="@+ID/stop_button" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:text="@string/stop_button" androID:textcolor="@color/text" /></linearLayout>
表现
<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID" package="com.MC.ChemPal" androID:versionCode="1" androID:versionname="1.0"> <uses-sdk androID:minSdkVersion="10" /> <application androID:icon="@drawable/icon" androID:label="@string/app_name"> <activity androID:name=".main" androID:label="@string/app_name"> <intent-filter> <action androID:name="com.MC.ChemPal.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity androID:name=".mainpage" androID:label="@string/app_name"> <intent-filter> <action androID:name="com.MC.ChemPal.MAINPAGE" /> <category androID:name="androID.intent.category.DEFAulT" /> </intent-filter> </activity> <activity androID:name=".Extra" androID:label="@string/app_name"> <intent-filter> <action androID:name="com.MC.ChemPal.EXTRA" /> <category androID:name="androID.intent.category.DEFAulT" /> </intent-filter> </activity> <activity androID:name=".help" androID:label="@string/app_name"> <intent-filter> <action androID:name="com.MC.ChemPal.HELP" /> <category androID:name="androID.intent.category.DEFAulT" /> </intent-filter> </activity> <activity androID:name=".search_page" androID:label="@string/app_name"> <intent-filter> <action androID:name="com.MC.ChemPal.SEARCH_PAGE" /> <category androID:name="androID.intent.category.DEFAulT" /> </intent-filter> </activity> </application></manifest>
java的
package com.MC.ChemPal;import androID.app.Activity;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.Widget.button;import androID.Widget.TextVIEw;public class mainpage extends Activity { /** Called when the activity is first created. */ button start_button,help_button,extra_button,stop_button; TextVIEw display; @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.mainpage); start_button = (button) findVIEwByID(R.ID.start_button); help_button = (button) findVIEwByID(R.ID.help_button); extra_button = (button) findVIEwByID(R.ID.extra_button); stop_button= (button) findVIEwByID(R.ID.stop_button); display = (TextVIEw) findVIEwByID(R.ID.main_Title_text); start_button.setonClickListener(new VIEw.OnClickListener() { public voID onClick(VIEw v) { // Todo auto-generated method stub Intent openSearchPage = new Intent("com.MC.ChemPal.SEARCH_PAGE"); startActivity(openSearchPage); } }); help_button.setonClickListener(new VIEw.OnClickListener() { public voID onClick(VIEw v) { // Todo auto-generated method stub Intent openHelp = new Intent("com.MC.ChemPal.HELP"); startActivity(openHelp); } }); extra_button.setonClickListener(new VIEw.OnClickListener() { public voID onClick(VIEw v) { // Todo auto-generated method stub Intent openExtra = new Intent("com.MC.ChemPal.EXTRA"); startActivity(openExtra); } }); stop_button.setonClickListener(new VIEw.OnClickListener() { public voID onClick(VIEw v) { // Todo auto-generated method stub onStop(); } }); }}解决方法 这是一个模拟器错误,当您尝试以横向模式启动活动时,您将看到它将从layout-land加载mainpage.xml,
机器人:screenorIEntation = “风景”
但是ctrl f12不起作用,这是一个BUG
http://code.google.com/p/android/issues/detail?id=13189
总结以上是内存溢出为你收集整理的android – 风景,肖像全部内容,希望文章能够帮你解决android – 风景,肖像所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)