Android 活动意图--不幸的是已停止
我想使用按钮意图活动来创建活动。 这是我的节目 这是我的XML:Android 活动意图--不幸的是已停止,android,android-intent,Android,Android Intent,我想使用按钮意图活动来创建活动。 这是我的节目 这是我的XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_p
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.ibaby_single_picture.MainActivity" >
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text = "123"
></Button>
</LinearLayout>
这是我的AndroidManifest:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.ibaby_single_picture.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> //↓I have written this.
<activity android:label="iBaby" android:name=".informationActivity"></activity>
</application>
这是我的信息活动。我使用Tabhost扩展活动
public class informationActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information_tabhost);
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tab1 = getActionBar().newTab();
tab1.setText("1");
tab1.setTabListener(new TabListener1(new information0()));
ActionBar.Tab tab2 = getActionBar().newTab();
tab2.setText("2");
tab2.setIcon(android.R.drawable.ic_menu_edit);
tab2.setTabListener(new TabListener1(new information1()));
ActionBar.Tab tab3 = getActionBar().newTab();
tab3.setText("3");
tab3.setIcon(android.R.drawable.ic_menu_search);
tab3.setTabListener(new TabListener1(new information2()));
ActionBar.Tab tab4 = getActionBar().newTab();
tab3.setText("3");
tab3.setIcon(android.R.drawable.ic_menu_search);
tab3.setTabListener(new TabListener1(new information3()));
getActionBar().addTab(tab1);
getActionBar().addTab(tab2);
getActionBar().addTab(tab3);
getActionBar().addTab(tab4);
}
private class TabListener1 implements ActionBar.TabListener {
private Fragment fragment;
public TabListener1(Fragment fragment) {
this.fragment = fragment;
}
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
ft.add(R.id.tabsample1, fragment);
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
ft.remove(fragment);
}
}
}
这是我的信息
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/tabsample1" >
</LinearLayout>
真的谢谢大家 informationActivity.java在哪里?此代码仅在存在另一个活动informationActivity时有效。
正如我们所知,intent用于将值从一个活动传递到另一个活动。因此,请确保InformationActivity创建良好且无错误请更改您的清单,在清单文件中添加包
android:label="iBaby"
android:name="com.example.ibaby_single_picture.informationActivity">
那是activity_main.xml吗?是的,那是activity_main.xml。发布StackTraceNouchMethodException:gotoinformationActivityFun Kaaro Yaarrrrrrrrrr请发送crashinent intent=new IntentgetApplicationContext,informationActivity.class;星状体;请改变,改变这个我已经解决了!我的活动有点不对劲。非常感谢。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/tabsample1" >
</LinearLayout>
android:label="iBaby"
android:name="com.example.ibaby_single_picture.informationActivity">