2017-06-21 3 views
-1

私のプロジェクト全体を通して、ボタンやクリック可能な画像ボタンを追加しました。しかし、なぜ私は.id.exampleの前に 'R'を使用しているのか分かりません。私はオンラインで質問しましたが、何も私に明確な答えを与えることはできません。誰でも説明できますか?「R」の目的は何ですか?

private Button DisplayRoutineButton; 
private Button ClearRoutineButton; 

private static int ImageID = 0; 

ImageView activityslotlocationa, activityslotlocationb, activityslotlocationc, activityslotlocationd, activityslotlocatione, activityslotlocationf; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.routineeditscreen); 

    myDb = new Database(this); 

    DisplayRoutineButton = (Button) findViewById(R.id.displayroutinebutton); 
    ClearRoutineButton = (Button) findViewById(R.id.clearroutinebutton); 

    // Display Routine Button 
    DisplayRoutineButton.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      Log.d("BUTTON CLICKED", "Display Schedule"); 
      Intent i = new Intent(MondayRoutineEdit.this, MondayRoutineDisplay.class); 
      Log.d("SUCCESSFUL", "Loading Monday Routine Display"); 
      startActivity(i); 
     } 
    }); 

    // Delete Routine Button 
    ClearRoutineButton.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      Log.d("BUTTON CLICKED", "Delete Routine"); 
      deleteRoutine(); 
      Log.d("SUCCESSFUL", "Routine Deleted"); 
     } 
    }); 

    // Audio Feedback 
    ImageView artactivity = (ImageView) this.findViewById(R.id.artactivityimage); 
    final MediaPlayer artsoundeffect = MediaPlayer.create(this, R.raw.art); 
    artactivity.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      artsoundeffect.start(); 
     } 
    }); 

    ImageView bedtimestoryactivity = (ImageView) this.findViewById(R.id.bedtimestoryactivityimage); 
    final MediaPlayer bedtimestorysoundeffect = MediaPlayer.create(this, R.raw.bedtimestory); 
    bedtimestoryactivity.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      bedtimestorysoundeffect.start(); 
     } 
    }); 
+2

"R"は "リソース"を表します。あなたはそれをgoogledする必要があります。 –

答えて

0

R.javaは、ビルドプロセス中に作成し、動的に生成されたクラスは、動的Androidアプリ内のJavaクラスで使用するために、(レイアウトするには、Androidのウィジェットに文字列から)すべての資産を識別することです。

詳しくはhereをご覧ください。

関連する問題