为什么另一个XML页面按钮的点击重定向不工作?重定向、按钮、页面、工作

2023-09-06 14:39:51 作者:空欢喜

我看着一切之前问这个。我在执行应用程序和新到Android,我需要重定向到我的 MapView的XML 登录按钮,点击。所以我写了意图加取得了明显文件中的活动,并试着写codeS一切可能的方式不同。而code不给任何错误。但我的模拟器停止发射后。我知道什么是错的,但我无法弄清楚。任何想法,为什么出现这种情况?

I looked in to everything before ask this. I am implementing an application and new to android, I need to redirect to my mapview xml when login button click. So i have written the intent plus made the activity in manifest file and tried writing codes every possible different way. And the code doesn't give any errors. But my emulator stops after launching. I know something is wrong but I can't figure it out. Any idea why that happens?

这是我的code

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final Button button=(Button)findViewById(R.id.loginbtn);
        button.setOnClickListener(new View.OnClickListener() 
        {

            @Override
            public void onClick(View v) 
            {

                switch (v.getId()) {
                case R.id.loginbtn:
                    Intent intent = new Intent (MainActivity.this, MapView.class);
                    startActivity (intent);
                    break;
                default:
                    break;}
                }
             }
          );
        }
     }
                /*if(username.getText().toString()==""&&password.getText().toString()=="")
                {

                     Intent i= new Intent("com.example.shaz.MAPVIEW");
                     startActivity(i);
                }
                else
                {
                    txt.setText("False");


                }
            */  

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myname"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.myname.MainActivity"
            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=".mapView"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.myname.MAPVIEW" />

                <category android:name="android.intent.category.DEFUALT" />
            </intent-filter>
        </activity>


    </application>

</manifest>

我也创建了名为地图的map_view XML文件在我的布局。

I have also created an xml file for map called map_view in my layouts.

因此​​,在每一个地方我搜索,这是他们怎么说新的意图是创造。

So in every where I searched this is how they say new intent is creating .

如果我做了什么比这重定向否则仿真器工作正常。 SO什么都的问题,我得到的是这种重定向部件内。

And the emulator works fine if I do something else than this redirection. SO what ever problem I got is within this redirection part.

推荐答案

默认在您的清单拼写错误

DEFAULT is spelled incorrectly in your Manifest