1
this 튜토리얼을 따라 안드로이드 애플리케이션에 탭 레이아웃을 구현했습니다. 나는 이미 기존의 안드로이드 앱을 가지고 있기 때문에 튜토리얼을 약간 조정해야했다. 나는 내가하는 것처럼 정확히 모든 것을했는지 확신하지만, 탭 레이아웃 활동을 열기로되어있는 버튼을 클릭 할 때마다 내 앱이 다운된다.tablayout 활동을 열면 내 앱이 다운 됨
홈페이지 tabLayout 활동 :
public class Bifrosttabs extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bifrosttabs);
TabHost tabHost = getTabHost();
//CRAFTING TAB
TabSpec craftTabSpec = tabHost.newTabSpec("Crafting");
craftTabSpec.setIndicator("Crafting", getResources().getDrawable(R.drawable.weaponsmith_logo));
Intent craftIntent = new Intent(this, Bifrost.class);
craftTabSpec.setContent(craftIntent);
//ADDITION INFO TAB
TabSpec infoTabSpec = tabHost.newTabSpec("Info");
infoTabSpec.setIndicator("Info", getResources().getDrawable(R.drawable.craft_info));
Intent infoIntent = new Intent(this, Bifrostinfo.class);
infoTabSpec.setContent(infoIntent);
tabHost.addTab(craftTabSpec);
tabHost.addTab(infoTabSpec);
}
홈페이지 tabLayout 활동 XML 파일 :
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
탭 레이아웃 활동을 엽니 다
버튼 방법 :
public void onClick (View v){
switch (v.getId()){
case R.id.button1:
Intent bifrost = new Intent (MainActivity.this, Bifrosttabs.class);
startActivity(bifrost);
break;
...rest of the code for other buttons
ㅁ 로그인 로그 파일 :
07-15 17:57:00.084: E/jdwp(14846): Failed writing handshake bytes: Broken pipe (-1 of 14)
07-15 17:57:06.186: E/AndroidRuntime(14846): FATAL EXCEPTION: main
07-15 17:57:06.186: E/AndroidRuntime(14846): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matthewstudios.gw2legendary/com.example.gw2legendary.tablayouts.Bifrosttabs}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matthewstudios.gw2legendary/com.example.gw2legendary.craftingactivities.Bifrost}: java.lang.NullPointerException
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.os.Handler.dispatchMessage(Handler.java:99)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.os.Looper.loop(Looper.java:137)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-15 17:57:06.186: E/AndroidRuntime(14846): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 17:57:06.186: E/AndroidRuntime(14846): at java.lang.reflect.Method.invoke(Method.java:511)
07-15 17:57:06.186: E/AndroidRuntime(14846): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-15 17:57:06.186: E/AndroidRuntime(14846): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-15 17:57:06.186: E/AndroidRuntime(14846): at dalvik.system.NativeStart.main(Native Method)
07-15 17:57:06.186: E/AndroidRuntime(14846): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matthewstudios.gw2legendary/com.example.gw2legendary.craftingactivities.Bifrost}: java.lang.NullPointerException
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.startActivityNow(ActivityThread.java:2023)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:749)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.widget.TabHost.setCurrentTab(TabHost.java:413)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.widget.TabHost.addTab(TabHost.java:240)
07-15 17:57:06.186: E/AndroidRuntime(14846): at com.example.gw2legendary.tablayouts.Bifrosttabs.onCreate(Bifrosttabs.java:34)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.Activity.performCreate(Activity.java:5104)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-15 17:57:06.186: E/AndroidRuntime(14846): ... 11 more
07-15 17:57:06.186: E/AndroidRuntime(14846): Caused by: java.lang.NullPointerException
07-15 17:57:06.186: E/AndroidRuntime(14846): at com.example.gw2legendary.craftingactivities.Bifrost.onCreate(Bifrost.java:160)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.Activity.performCreate(Activity.java:5104)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-15 17:57:06.186: E/AndroidRuntime(14846): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-15 17:57:06.186: E/AndroidRuntime(14846): ... 21 more
07-15 17:57:14.967: E/fb4a(:<default>):MmsConfig(14952): MmsConfig.loadMmsSettings mms_config.xml missing uaProfUrl setting
나는 여러분에게 줄 수있는 중요한 코드를 모두 알려 드렸습니다. 내가 아무 것도 잊어 버렸다면 알려주세요.
logcat에서 NullPointerException 다음에 오는 것은 무엇입니까? 문제가있는 곳에서 가장 가능성이 높습니다 – CodingIntrigue
@ Blade0rz 방금 전체 logcat 파일을 붙여 넣었습니다. 내 편집을 확인하십시오 – Guy
Bifrost 클래스의 행 번호 160에 오류가 있습니다. 일부 변수를 시작하지 않았습니다. – Laksh