每当尝试在ListView上单击某个项目时,我都试图启动一项活动
我在我的项目中使用数据库,在我的项目中使用全局变量
但无法在项目中启动GalleryFileActivity活动
如果您需要了解每个部分,还将提供
感谢您一直以来为追求完美所做的努力

公共类DataListView扩展ListActivity {

final private ArrayList<String> results = new ArrayList<String>();
private String tableName = DBHelper.tableName;
private SQLiteDatabase newDB;
private String Path;
final private ArrayList<String> pikh = new ArrayList<String>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final global folder = ((global)getApplicationContext());
    openAndQueryDatabase();

    displayResultList();


}
private void displayResultList() {
    TextView tView = new TextView(this);
    tView.setText("data is");
    getListView().addHeaderView(tView);


    setListAdapter(new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, results));

    ListView lstView = getListView();


   lstView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
   lstView.setTextFilterEnabled(true);

}
    public void onListItemClick(
            ListView parent, View v, int position,long id, global folder)
            {
        String pos=results.get(position-1);
        super.onListItemClick(parent, v, position, id);
                Toast.makeText(this,
                    "You have selected "  + results.get(position-1) ,
                    Toast.LENGTH_SHORT).show();
                folder.setsubfolder (pos);
            **startActivity(new Intent(this,GalleryFileActivity.class));**
            }

            public void onClick(View view) {
                ListView lstView = getListView();

            }

private void openAndQueryDatabase() {
    try {
        DBHelper dbHelper = new DBHelper(this.getApplicationContext());
        newDB = dbHelper.getWritableDatabase();
        Cursor c = newDB.rawQuery("SELECT Path, Header FROM resource1  "
                 , null);

        if (c != null ) {
            if  (c.moveToFirst()) {
                do {

                    Path = c.getString(c.getColumnIndex("Path"));
                    String Header = c.getString(c.getColumnIndex("Header"));

                    results.add( Path + "    " + Header);


                }while (c.moveToNext()) ;

            }
        }
    } catch (SQLiteException se ) {
        Log.e(getClass().getSimpleName(), "Could not create or Open the database");
    } finally {
        if (newDB != null)
            newDB.execSQL("DELETE FROM " + tableName);
            newDB.close();
    }

}


}

最佳答案

该代码看起来正确。

听起来您的清单中可能没有声明GalleryFileActivity

检查您的logcat输出-那里可能有一个例外提到了这一点。

08-27 05:29