2016-06-23 11 views
0

私はアンドロイドが新しく、ユーザーのトレーニングに役立つアプリを作成しようとしています。私はこの質問がかなり大きくて多少曖昧であることを理解していますので、私が使用できる答えが得られることを期待して説明します。Androidの設定方法オプションの選択と画面の表示

問題は、さまざまなアクティビティを設定する方法と、相互にやりとりする必要があることに苦労していることです。これは、次のようになります。

_________  _________  _________  
|   |  |   |  |   | 
|   |  |   |  |   | 
|   |  |   |  |   | 
| 1 | ---> |  2 | --> | 3  | 
|   |  |   |  |   | 
|   |  |   |  |   | 
|_________|  |_________|  |_________| 
    menu  options select options shown 

に、ユーザはそれがなるべき彼のオプションを選択したが、AFTER:

_________  _________  
|   |  |   | 
|   |  |   | 
|   |  |   | 
| 1 | ---> |  3 | 
|   |  |   | 
|   |  |   |  
|_________|  |_________| 
    menu   options shown 

をユーザーがもスクリーン3からバックスクリーン2に移動する機能を持っている必要があります彼の選択肢を変える私は単にこれに対する最良のアプローチが何であるか分かりません。特に、バックボタンの相互作用がある。

3つのアクティビティを持っていて、それらを最適にリンクすることはできますか?可変レイアウトで2つのアクティビティを持つことができますか?多分フラグメントを使うことによって?それとももっと良い方法がありますか?

答えて

1

あなたはメニュー機能をもたらし、あなたはオプションに基づいてフラグメントを読み込むことができますFrameLayoutコンテナを持ってNavigationViewActivityDrawerLayoutを持つことができます。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context=".home.HomeActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:background="?attr/colorPrimary" 
      android:minHeight="?attr/actionBarSize" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      app:layout_scrollFlags="scroll|enterAlwaysCollapsed" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 
    </android.support.design.widget.AppBarLayout> 
    <FrameLayout 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 
</LinearLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    app:itemBackground="@color/white" 
    app:itemTextAppearance="?attr/textAppearanceListItem" 
    app:menu="@menu/drawer" /> 

+0

なぜdraweLayoutが必要なのです:あなたの活動のレイアウトファイルは、以下のようなものになることができますか?私は既存のレイアウトでframeLayoutを使用できませんでしたか? – Mischa

+0

DrawerLayoutはメニューの引き出しをスライドするためのものです – himanshu1496

1

SharedPreferenceを使用する必要があります。 Activity2では、sharedPreferenceStringを取得する必要があります。値が設定されている場合は、activity3を開始するだけで、そうでない場合はユーザーが選択してsharedPreferenceStringを設定する必要があります。 あなたのactivity3では、そのsharedPreferenceStringを削除することができます。そのため、activity2を入力すると、それはもはや設定されず、ユーザーは選択agianを取ることができます。ここ は、ユーザーがクリックが好みかどうかを確認し、その活動を開くと好み

  • に保存先のアクティビティ名または番号(識別)をクリックしてオンdocs

  • 0
    1. です。
    2. 好みではnullのデフォルト値のリターン場合は、開いているアクティビティ2
    関連する問題