I was just started to learn Android programming and I was trying to make a simple Android SQLite database and I encountered some error in my ".java" files in the "src" such as "R cannot be resolved to a variable" and an error in my xml at menu folder say that "Error: No resource found that matches the given name (at 'title' with value '@string/action_settings'). database_android_satu.xml /DatabaseAndroid/res/menu line 5 Android AAPT Problem" I deeply gratitude for your kindness of your answer and maybe some advice..
here is my .java files :
package com.db.satu;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
public class DatabaseAndroidSatu extends Activity {
DatabaseManager dm;
EditText nama, hobi;
Button addBtn;
TableLayout tabel4data;// tabel for data
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
dm = new DatabaseManager(this);
tabel4data = (TableLayout) findViewById(R.id.tabel_data);
nama = (EditText) findViewById(R.id.inNama);
hobi = (EditText) findViewById(R.id.inHobi);
addBtn = (Button) findViewById(R.id.btnAdd);
addBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpKamuta();
}
});
updateTable();
}
protected void simpKamuta() {
try {
dm.addRow(nama.getText().toString(),hobi.getText().toString());
Toast.makeText(getBaseContext(),
nama.getText().toString() + ", berhasil disimpan",
Toast.LENGTH_SHORT).show();
updateTable();
kosongkanField();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getBaseContext(), "gagal simpan, " +
e.toString(),Toast.LENGTH_LONG).show();
}
}
protected void kosongkanField(){
nama.setText("");
hobi.setText("");
}
protected void updateTable() {
// TODO Auto-generated method stub
while (tabel4data.getChildCount() > 1) {
tabel4data.removeViewAt(1);
}
ArrayList<ArrayList<Object>> data = dm.ambilSemuaBaris();//
for (int posisi = 0; posisi < data.size(); posisi++) {
TableRow tabelBaris = new TableRow(this);
ArrayList<Object> baris = data.get(posisi);
TextView idTxt = new TextView(this);
idTxt.setText(baris.get(0).toString());
tabelBaris.addView(idTxt);
TextView namaTxt = new TextView(this);
namaTxt.setText(baris.get(1).toString());
tabelBaris.addView(namaTxt);
TextView hobiTxt = new TextView(this);
hobiTxt.setText(baris.get(2).toString());
tabelBaris.addView(hobiTxt);
tabel4data.addView(tabelBaris);
}
}}
here is my .xml files that located in menu folder of the project : its contain an error: "Error: No resource found that matches the given name (at 'title' with value '@string/action_settings'). database_android_satu.xml /DatabaseAndroid/res/menu line 5 Android AAPT Problem"
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.db.satu.DatabaseAndroidSatu" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>