Ich bin neu im Bereich Android und habe bei der ersten Funktion schon einen Fehler.
(Falls es relevant ist: Ich benutze zur Zeit Eclipse mit dem dem neusten Java SDK)
Ich möchte gerne die Funktion findviewById nutzen für ein Textview nutzen,
jedoch bekomme ich einen Error… (Text cannot be resolved or ist not a field)
Mein Main Class Code:
package com.example.testprojekt;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class Main extends Activity {
public TextView tw;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tw = (TextView) findViewById(R.id.Text);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Meine XML Datei:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Main" >
<TextView
android:id="@+id/Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="94dp"
android:layout_marginTop="90dp"
android:text="test" />
</RelativeLayout>