gpt4 book ai didi

android - 为什么另一个 xml 页面的按钮单击重定向不起作用?

转载 作者:行者123 更新时间:2023-11-29 21:08:59 24 4
gpt4 key购买 nike

在问这个问题之前,我查看了所有内容。我正在实现一个应用程序并且是 android 的新手,当 login button click 时,我需要重定向到我的 mapview xml。所以我已经编写了 intent 加上 activity in manifest 文件,并尝试以各种可能的不同方式编写代码。并且代码没有给出任何错误。但是我的模拟器在启动后停止了。我知道出了点问题,但我想不通。知道为什么会这样吗?

这是我的代码

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");


}
*/

list

<?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 创建了一个名为 map_view 的 xml 文件。

所以在我搜索的每个地方,这就是他们所说的新 Intent 正在创造的方式。

如果我做的不是这个重定向,模拟器也能正常工作。所以我遇到的任何问题都在这个重定向部分。

最佳答案

DEFAULT 在您的 list 中拼写错误

关于android - 为什么另一个 xml 页面的按钮单击重定向不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23572913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com