FindViewById wobei ID eine dynamische Zeichenfolge ist

Ich habe einen Tisch mit 40 Feldern und jeder hat eine ID. Wenn ich ein Bundle aus einer anderen Aktivität übergebe, muss ich Note, Farbe und ID aus diesem Bundle extrahieren. Und dann wird die App Text ändern / hinzufügen und den Hintergrund des durch die extrahierte ID angegebenen Quadrats ändern. Jedes Quadrat hat die ID des int-Formats. Jede ID, die von einer anderen Aktivität übergeben wird, hat ein Zeichenfolgenformat. Ich kann nicht herausfinden, wie ich es schaffe, ViewById (R.id.passed_id) zu finden und wie zwei verschiedene Formate zusammenarbeiten. Ich habe versucht, die ID jedes Quadrats zu ändern, aber Eclipse sagt, dass die ID einen Buchstaben und eine Nummer haben muss. Ich bin verloren ... Hier ist der Code:

package com.tt;

 import android.os.Bundle;
 import android.app.Activity;
 import android.content.Intent;
import android.content.res.Resources;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity
 {
String gotNotes;
String n;
String gotDOW;
String gotID;
public String Id;
String gotHour;
TextView notes;
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initialize();
    Button settings = (Button)findViewById(R.id.settings);

    Bundle gotPackage = getIntent().getExtras();
    if (gotPackage != null){
    gotNotes = gotPackage.getString("AddedNote");
   // if (gotNotes.equals(" ")){n = "Empty";}else n = gotNotes;
    //gotDOW = gotPackage.getString("Day");
    //gotHour = gotPackage.getInt("Hour");
    gotID = gotPackage.getString("ID");

    Id = gotID;
    notes.setText(gotNotes + (" \n") + gotID);

    }
    else{}



  settings.setOnClickListener(new OnClickListener()
    {



          public void onClick(View v)
         {
              Intent i = new Intent(v.getContext(),Settings.class);
              startActivityForResult(i,0);
         }

     });

   }

  private void initialize() 
       {
    // TODO Auto-generated method stub


    notes = (TextView)findViewById(R.id.);
    notes.setGravity(Gravity.CENTER);
    notes.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
}



    @Override
            public boolean onCreateOptionsMenu(Menu menu) 
             {
               getMenuInflater().inflate(R.menu.activity_main, menu);
               return true;

             }

      }

AKTUALISIEREN

Ok.. here's the log:

12-27 16:18:55.661: D/AndroidRuntime(12497): Shutting down VM
12-27 16:18:55.661: W/dalvikvm(12497): threadid=1: thread exiting with uncaught exception (group=0x40abf228)
12-27 16:18:55.671: E/AndroidRuntime(12497): FATAL EXCEPTION: main
12-27 16:18:55.671: E/AndroidRuntime(12497): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tt/com.tt.MainActivity}: java.lang.NullPointerException
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.ActivityThread.access$600(ActivityThread.java:139)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.os.Looper.loop(Looper.java:154)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.ActivityThread.main(ActivityThread.java:4944)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at java.lang.reflect.Method.invokeNative(Native Method)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at java.lang.reflect.Method.invoke(Method.java:511)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at dalvik.system.NativeStart.main(Native Method)
12-27 16:18:55.671: E/AndroidRuntime(12497): Caused by: java.lang.NullPointerException
12-27 16:18:55.671: E/AndroidRuntime(12497):    at com.tt.MainActivity.initialize(MainActivity.java:69)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at com.tt.MainActivity.onCreate(MainActivity.java:30)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.Activity.performCreate(Activity.java:4531)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
12-27 16:18:55.671: E/AndroidRuntime(12497):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150)
12-27 16:18:55.671: E/AndroidRuntime(12497):    ... 11 more

Antworten auf die Frage(3)

Ihre Antwort auf die Frage