Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 风景,肖像大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在搜索这个网站的答案,但我找不到一个.我的 Android应用程序不是在我的模拟器中从纵向交换到横向它只是显示侧面纵向屏幕.
我已经创建了一个带有匹配的xml名称的layout和layout-land文件夹,依此类推.但它似乎没有采用布局版本.我没有onConfig()函数或任何其他所以我想知道是否有人可以帮助???

@H_937_6@mainpage.xml layout-land

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://scheR_441_11845@as.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://scheR_441_11845@as.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://scheR_441_11845@as.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 – 风景,肖像所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。