2017-09-12 23 views
0

質問タグは、stackoverflowでよく知られているかもしれませんが、私はここにいくつかの状況があります。私は、私のアプリケーションには、アプリケーション全体で見える下のメニューバーがあることを達成したいと思います。だから私は、ビューを追加し、以前に、それはのようだったAndroidデータバインディングビューのタグが正しく表示されません:null

@Override 
public void setContentView(int layoutResID) { 
    fullLayout = (RelativeLayout) getLayoutInflater().inflate(R.layout.activity_base, null); 
    configureToolbar(fullLayout); 
    subActivityContent = (FrameLayout) fullLayout.findViewById(R.id.content_frame); 
    getLayoutInflater().inflate(layoutResID, subActivityContent, true); 
    super.setContentView(fullLayout); 
} 

を次のように私のベースの活動でそれを設定します。現在、いくつかのページにデータ・バインディングがあり

@Override 
public void setContentView(int layoutResID) { 
    View view = getLayoutInflater().inflate(layoutResID, null); 
    configureToolbar(view); 
    super.setContentView(view); 
} 

。これは次のように呼ばれます:

2行目でエラーが発生しています。

ここは自分のアクティビティレイアウトです。 1つ目はアクティビティベースの共通レイアウト、2つ目はデータバインディングレイアウトです。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_height="match_parent"> 

<include android:id="@+id/app_bar" layout="@layout/app_bar" /> 

<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<com.roughike.bottombar.BottomBar 
    android:id="@+id/bottomBar" 
    android:layout_width="match_parent" 
    android:layout_height="60dp" 
    android:layout_alignParentBottom="true" 
    app:bb_tabXmlResource="@xml/bottombar_tabs" /> 

第二レイアウト:私は、これはあなたが活動を作成しているので、アプリケーション全体で下部のナビゲーションバーを実装するための良い解決策だとは思わない

<layout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:map="http://schemas.android.com/apk/res-auto"> 

<data> 
    <import type="android.view.View" /> 

    <variable 
     name="item" 
     type="io.ppp.views.someActivity" /> 
</data> 

<RelativeLayout 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/root_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="io.ppp.views.someActivity"> 

    <include android:id="@+id/app_bar" layout="@layout/app_bar" /> 
    <!--<include layout="@layout/activity_base" />--> 




    <WebView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webViewLoader" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 


    <RelativeLayout 
     android:id="@+id/progress_indicator" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="false" 
     android:layout_centerInParent="true" 
     android:visibility="@{item.loading ? View.VISIBLE : View.GONE}"> 

     <ProgressBar 
      android:id="@+id/search_progress" 
      style="@style/Base.Widget.AppCompat.ProgressBar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_alignParentTop="true" 
      android:indeterminate="true" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_gravity="center" 
      android:layout_marginTop="50dp" 
      android:text="@{item.loadingText}" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 

    </RelativeLayout> 

</RelativeLayout> 

答えて

1

、ユーザーがアクティビティを変更するたびに、画面の下部に固定要素を保持する代わりに、画面が完全にスワップ(下部バーが含まれています)されることが明確になりますユーザーはアプリケーション全体に自分自身を誘導するために使用します。

Androidでのボトムナビゲーションの実装は、iOSの場合よりもはるかに厄介です。画面の数が多い場合は、1つのアクティビティとフラグメント(たくさんの場合)が必要です。応用。あなたに

私のアドバイスは、断片にあなたの活動を変革下のバーとフラグメントのコンテナと下部のナビゲーション活動を実施し、そこから行くことです。

API25からは、BottomNavigationViewが導入されました。これにより、あなたの人生が楽になり、GitHubのBottomBarライブラリを使用する必要はありません。私はまたAHBottomNavigationを見るための助言、それは私には本物のものより完全であるように見える、あなたの下のバーより優れたコントロールと選択肢を与える。

+0

こんにちは、あなたのコメントをいただきありがとうございます。私のアプリケーションの下部バーは、2ページと残りのアクティビティの間で交換するためにのみ使用され、ナビゲーションは上部から機能します。だから、それは完全にタブに依存するアプリケーションのようなものではありません。 – darkprince

+0

それは問題ですが、2つの単一ページでもそれを行うのは良い方法ではありません。 1つのアクティビティがあり、フラグメントコンテナがあり、コンテナ内のビューをスワップする必要があります。 – Ricardo

+0

私の知っていることはわかりますが、私の上司はプロジェクトの途中でボトムバーを導入しています。もし私がエラーを避けることができれば、それは役に立つでしょう。 – darkprince

関連する問題