2016-06-26 5 views
0

メニューがあり、次のアクティビティを呼び出して、ユーザーが計算してから次のページまたはホームページを返すことができますが、実行方法はわかりませんこれは... Jaはいろいろ試してみましたが、そうでない場合や、別のページで動作している場合は、すべてのanetrioresメニューが消えてしまいます。メニューをクリックした後に別のアクティビティを呼び出す

私はプログラミングが初めてで、特にアンドロイドを使用しています。

MainActivity:

@SuppressWarnings("StatementWithEmptyBody") 
    @Override 
    public boolean onNavigationItemSelected(MenuItem item) { 
     // Handle navigation view item clicks here. 
     int id = item.getItemId(); 

     if (id == R.id.nav_camera) { 
      //I want to call the page " calculations" here. 

     } else if (id == R.id.nav_gallery) { 

    } 

     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     drawer.closeDrawer(GravityCompat.START); 
     return true; 
    } 
} 

android_manifest.xml:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.stark.hello_world"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity 
      android:name=".Splashscreen" 
      android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme.NoActionBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <activity 
      android:name=".Calculos" 
      android:label="@string/action_help" 
      android:parentActivityName=".MainActivity" /> 

    </application> 

</manifest> 

calculos.xml

<RelativeLayout 
    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:paddingLeft="4dp" 
    android:paddingRight="4dp" 
    android:paddingTop="4dp" 
    android:paddingBottom="4dp" 
    tools:context=".MainActivity" 
    android:background="#ff0fffab"> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="SEM" 
     android:id="@+id/textView" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" 
     android:textSize="@dimen/abc_text_size_display_3_material" 
     android:textColor="#ffffffff" /> 

    <EditText 
     android:id="@+id/email_address" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:inputType="number" /> 
</RelativeLayout> 

app

+0

質問は不明です。単にアクティビティを呼び出すだけでかなり基本的なので、私はあなたが求めているものではないと思います。あなたは肉が何であるかを明確にする必要があります。 "...そして、次のページやホームページを返したい。" –

+0

@MalithLakshan はい、申し訳ありませんが、私はメニュー項目をクリックして、ページやアクティビティの特派員に指示することを望んでいますが、これは起こっていないと私はする方法がわからないいくつかの場所でそれについて読む。 –

答えて

1

私はあなたの質問についてはよく分からないが、私はあなたがメニュー項目がクリックされた後、新たな活動を開きたいと思いますか?あなたがテントを起動する必要があり、このために

あなたの場合 - 私はあなたのコード

public boolean onNavigationItemSelected(MenuItem item) { 
    // Handle navigation view item clicks here. 
    int id = item.getItemId(); 

    if (id == R.id.nav_camera) { 
     //I want to call the page " calculations" here. 
     //with this code you can call a new activity 
     Intent intent = new Intent(this, YourActivity.class); 
     startActivity(intent); 
    } else if (id == R.id.nav_gallery) { 
     //create another Intent here and navigate to the correct activity 
} 

に必要な行を追加しました。しかし、私が代わりに活動の断片を使用することをお勧めして使用することになりgetFragmentManager().beginTransaction().replace(YourFragment.newInstance());

1

セットに親アクティビティあなたのANDROID_MANIFEST

<activity 
     android:name=".Help" 
     android:label="@string/action_help" 
     android:parentActivityName=".MainActivity" /> 
+0

どうすればいいですか? –

+0

ok私は私の答え@PauloRobertoを編集しました –

+0

はストレッチのマニフェストを変更しましたが、サイドメニューの "計算"をクリックするとまだページの計算を呼び出さないので、それ以上の変更を加える必要がありますか?例えばコードですか? –

関連する問題