Code deklariert.Start ListActivity mit Absicht von Hauptaktivität und Fehler finden, haben Sie diese Aktivität in Ihrem AndroidManifest.xml
public class Season extends ListActivity {
private DataBaseHelper db;
private String[] Name;
private String[] Teedad;
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.season);
db = new DataBaseHelper(this);
refresher();
setListAdapter(new AA());
listView=(ListView)findViewById(R.id.list);
}
class AA extends ArrayAdapter<String>{
public AA(){
super(Season.this,R.layout.raw_season,Name);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater in = getLayoutInflater();
View row = in.inflate(R.layout.raw_season, parent,false);
TextView name = (TextView) row.findViewById(R.id.name_season);
TextView teedad = (TextView) row.findViewById(R.id.teedad_dastan);
name.setText(Name [position]);
teedad.setText(Teedad [position]);
return (row);
}
}
}
private void refresher(){
db.openDataBase();
int save = db.shomaresh_field("datastorys", "season");
Name = new String[save];
Teedad = new String[save];
for (int i = 0; i <save; i++) {
Name[i] = db.namayesh_fasl("datastorys", i);
Teedad[i] = db.shomaresh_dastan("datastorys", Name[i].toString())+"";
}
db.close();
}
}
Manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.farhad.bookdb">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.example.farhad.bookdb.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.farhad.bookdb.Season">#I think, Is there any problem?#
</activity>
</application>
</manifest>
Xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:id="@+id/list" />#I define here list#
</RelativeLayout>
MainActivity-Code
public class MainActivity extends Activity {
Button btn;
Cursor c = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button)findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DataBaseHelper myDbHelper = new DataBaseHelper(MainActivity.this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
Intent intent = new Intent(MainActivity.this,Season.class);
startActivity(intent);
} catch (SQLException sqle) {
throw sqle;
}
}
});
}
}
[1]: FATAL ERROR : main have you declared this activity in your AndroidManifest.xml?
FATAL ERROR : main have you declared this activity in your AndroidManifest.xml?
Blockquote Ich habe zwei Tage auf dieser Anwendung arbeiten, aber es gibt ein Problem, das zu verwechseln. Ich habe die meiste Post darüber gelesen, aber ich konnte es nicht lösen, bitte hilf mir.
Stellen Sie sicher, dass Ihr 'Paketname' korrekt geschrieben wurde, bevor Sie mit' 'com.example.farhad.bookdb.Season' beginnen. Was ist Ihr Paketname? –
Überprüfen Sie den Paketnamen in Ihrer Season.java. Erste Zeile der Saison.java. –
mein Paketname ist com.example.farhad.bookdb –