私はいつも私は、Androidを学ぶためにしようとしていると私はhttp://developer.android.com/resources/tutorials/views/hello-tabwidget.htmlにまとめられているすべてのステップを追った私は、Eclipseこれはなぜクラッシュですか?どのようにデバッグするのですか?
を使用していますが、ときに私は実際に(私のLG革命でコードを実行するので、今、過去にXcodeのを使用しましたFroyo 2.2.1)、私はクラッシュしています。
デバッグの方法がわかりませんが、なぜこれがクラッシュするのかわかりません。どんな助けもありがとう。
私は(私が作った唯一の変更thatsの私はそれがクラッシュしなければならないとは思わない)すべての3つのタブに同じ画像を使用
ここに私のコードここ
package com.oneorangetree.shit;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
public class HelloTabWidgetActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Resource object to get drawable
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, ArtistsActivity.class);
spec = tabHost.newTabSpec("artists").setIndicator("Artists", res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, AlbumsActivity.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums", res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, SongsActivity.class);
spec = tabHost.newTabSpec("songs").setIndicator("Songs", res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}
は私のマニフェストファイルです
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.oneorangetree.shit"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloTabWidgetActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
私はあなたには、いくつかを投稿するまで、あなたは何の答えを得るしないことを保証することができますコード。 – Peaches491
クラッシュを見つける最も良い方法は、LogCatをチェックすることです。それは基本的にアンドロイドのシステムログです。 'SDK/tools'フォルダのddmsアプリケーションか、' Window-> Add view-> other-> LogCat'を使ってeclipseで見つけることができます。そこに例外があるはずです(AndroidRuntimeタグで赤で印刷されています)。あなたがそれを持ってから、それを掲示し、関連コードを追加してください。 –
私の質問への答えはあなたのためにこれに答えるでしょうhttp://stackoverflow.com/questions/2209406/issues-with-android-tabhost-example – KevinDTimm