我有一個問題,我尋求一點,但我不明白爲什麼它追加...類型的表達式必須是一個數組類型,但它解決了長期
如果有人能幫助我。
public class Menu extends Activity
{
private SQLiteDatabase db;
private GridView grid;
private Button add;
private Button info;
private Button deco;
private String lab[];
private String id[];
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
grid = (GridView) findViewById(R.id.grid);
add = (Button) findViewById(R.id.add_account);
info = (Button) findViewById(R.id.info);
deco = (Button) findViewById(R.id.deconnexion);
add.setOnClickListener(add_listener);
info.setOnClickListener(info_listener);
deco.setOnClickListener(deco_listener);
try
{
db = openOrCreateDatabase("TMP_TTTT_TLA", MODE_PRIVATE, null);
}
catch(SQLiteException e)
{
Toast.makeText(Menu.this, "Impossible d'avoir accès à la base de donnéee.", Toast.LENGTH_LONG).show();
}
Cursor c = db.rawQuery("SELECT a_id, a_name FROM Account", null);
lab = new String[c.getCount()];
id = new String[c.getCount()];
int i = 0;
if (c.getCount() != 0)
{
if (c.moveToFirst())
{
do
{
lab[i] = c.getString(c.getColumnIndex("a_name"));
id[i] = c.getString(c.getColumnIndex("a_id"));
i++;
}
while(c.moveToNext());
}
}
c.close();
grid.setAdapter(new Adapter_Menu(this, lab));
grid.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent, View v, int position, long id)
{
Intent x = new Intent(Menu.this, Account_View.class);
x.putExtra("Id", id[position]);
startActivity(x);
}
});
}
}
來自該行的問題:
x.putExtra("Id", id[position]);
這是說的類型的表達式必須是一個數組類型,但它解析爲長。
請幫助我。
你可以添加stacktrace與異常消息嗎? – micha