T
tilo68
Neues Mitglied
- 0
Hallo
ich bin newbi bei App programmieren und versuche mich gerade an einfachen Beispielen.
Zur Zeit scheiter ich wie viele andere an der Fehlermeldung "R.id cannot be resolved"
das habe ich versucht:
- main.xml angepasst
- import android.R;
- Rechte des Projekt-Verzeichnis auf 777 (ich arbeite unter Linux) gesetzt
- Project/clean durchgeführt
- Datei R.java gelöscht und neu erzeugt
- restart von eclipse
aber nichts hilft :-( könnt Ihr mir weiter helfen .... ich will nicht direkt beim 2ten Project scheitern
besten dank für die Hilfe
Hier der code:
minigps
main.xml
strings.xml
R.java
ich bin newbi bei App programmieren und versuche mich gerade an einfachen Beispielen.
Zur Zeit scheiter ich wie viele andere an der Fehlermeldung "R.id cannot be resolved"
das habe ich versucht:
- main.xml angepasst
- import android.R;
- Rechte des Projekt-Verzeichnis auf 777 (ich arbeite unter Linux) gesetzt
- Project/clean durchgeführt
- Datei R.java gelöscht und neu erzeugt
- restart von eclipse
aber nichts hilft :-( könnt Ihr mir weiter helfen .... ich will nicht direkt beim 2ten Project scheitern
besten dank für die Hilfe
Hier der code:
minigps
Code:
package com.minigps;
import android.R;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
public class minigps extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
}
public class MyLocationListener implements LocationListener{
@Override
public void onLocationChanged(Location loc){
loc.getLatitude();
loc.getLongitude();
String Text = "Lat = " + loc.getLatitude() + "|Long = " + loc.getLongitude();
Toast.makeText( getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
final TextView tv = (TextView) findViewById(R.id.text);
tv.setText(tv.getText()+ "||" + Text);
}
public void onProviderDisabled(String provider){
public void onProviderEnabled(String provider){
public void onStatusChanged(String provider, int status, Bundle extras){
}
}
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text"
android:layout="@+layout/main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, minigps!</string>
<string name="app_name">minigps</string>
</resources>
Code:
package com.minigps;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int text=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}