2016-03-28 13 views
0

2人目のアクティビティを持つアプリがあります.2番目のアクティビティには問題のないアプリのタイトル付きアクションバーがあります。 しかし、私のランチャー活動では、バーはアンドロイドスタジオのディスプレイに表示されますが、実際のアプリでは表示されません... 何が起こって何が起こっている? は、ここに私のxmlです:アンドロイドスタジオで表示されたアクションバーは実際のアプリケーションでは表示されません

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
    tools:context=".Menu_Activity"> 

<ListView 
    android:id="@+id/list" 
    android:layout_width="wrap_content" 
    android:layout_height="40dp" 
    android:layout_weight="0.99" 
    android:dividerHeight="2px"> 

</ListView> 

<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" /> 

<Button 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Download content" 
    android:textColor="#FFFFFF" 
    android:id="@+id/button" 
    android:background="@drawable/buttonshape" /> 

</LinearLayout> 

とここにバーが表示されているxmlです:

Imは両方のケースでAppCompatActivityを拡張以外のjavaファイル内のバーに関する何もしていない
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:gravity="center"> 



<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 

    /> 

<ListView 
    android:id="@+id/list" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:divider="#FF000080" 
    android:dividerHeight="2px"> 


</ListView> 



</LinearLayout> 

。ここで

は、スタイルファイルです:

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 



<style name="AppTheme.AppBarOverlay"  parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

</resources> 

あなたの助けをいただき、ありがとうございます。

+1

Androidスタジオでは、使用可能なテーマを使用してレイアウトの外観を表示できます。特にツールを使用している場合:コンテキスト。 Android Studioに間違ったテーマが選択されている可能性があります。マニフェストファイル内でのあなたの活動とアプリケーションには、どのようなテーマがありますか? – lodlock

+0

これらのXMLファイルのいずれにも 'android.support.v7.widget.Toolbar'が表示されません。なぜあなたはAndroid Studioプレビューウィンドウでそれらを見ますか? –

答えて

2

可能性1: アプリがActivityの場合は、AppCompatActivityに変更してください。

可能性2: "styles.xml"という名前の異なるバージョンのファイルがありますか?それらのどれもAppTheme.NoActionBarという名前のテーマがないことを確認してください。

アプリを実行している端末は、そのバージョンでより適切なテーマを取得します。たとえば、ファイル名がstyles.xml(v21)の場合、Lollipop以上のデバイスで使用されます。

+0

可能性は私のために働いています、ありがとう –

0

あなたは何らかの理由で、アクションバーに表示されないアクティビティのコンテンツを含むlistViewを表示したいと考えています。ここに私が私のためにしたことがあります。メインメソッドではAppCompactActivityを拡張し、メソッド自体でlistViewをListView listView;のように宣言した後、メインオブジェクトのonCreateメソッドで、単にlistView = (ListView) findViewById(R.id.thelistid)を使用してリストのIDに接続しますlistView.setAdapter(nameOfYourAdapter)のような内容でリストを埋めるべきアダプターと呼ばれています。

関連する問題