2016-11-15 55 views
-1

美好的一天,我知道如何通過按鈕單選按鈕將主頁鏈接到另一個活動頁面嗎?帶按鈕的單選按鈕鏈接? [Android Studio]

+0

也許這會指向你在正確的方向:http://stackoverflow.com/questions/4186021/how-to-start-new-activity-on-button-click –

+0

是的,它是簡單的,因爲你正在使用按鈕 –

+0

@趙林感謝您的回覆。對此,我真的非常感激。我最初的計劃是讓用戶選擇通過單選按鈕 –

回答

0
final RadioButton admin = (RadioButton) findViewById(R.id.radio1); 
final RadioButton employee = (RadioButton) findViewById(R.id.radio2); 
final Button go = (Button) findViewById(R.id.button1); 
     go.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      if (admin.isChecked()) 
      { 
      Intent Intents= new Intent(YourActivity.this, Admin.class); 
      startActivity(Intents); 
      } 
      else if (employee.isChecked()) 
      { 
      Intent Intentm = new Intent(YourActivity.this, Employee.class); 
      startActivity(Intents); 
      } 
      } 
     }); 

希望這會有所幫助。

+0

感謝您的幫助@John Joe。我首先嚐試 –

+0

歡迎。 ...... –