Android:将光标结果转换为字符串[]
我的android应用程序中有一个查询,可以从自定义表中提取所有图像路径,并将它们显示到图库中。问题是我的数据库似乎无法将数据库的一行转换为字符串[]。我可以很容易地获得listArray的结果,但我需要字符串或字符串数组中的图像路径。我想能够在画廊中点击一个图像,让它拉上全屏,以便能够放大或删除它等等。这是我使用的基本查询Android:将光标结果转换为字符串[],android,string,cursor,Android,String,Cursor,我的android应用程序中有一个查询,可以从自定义表中提取所有图像路径,并将它们显示到图库中。问题是我的数据库似乎无法将数据库的一行转换为字符串[]。我可以很容易地获得listArray的结果,但我需要字符串或字符串数组中的图像路径。我想能够在画廊中点击一个图像,让它拉上全屏,以便能够放大或删除它等等。这是我使用的基本查询 public void listimages() { SimpleCursorAdapter adapter; String[] columns = {
public void listimages() {
SimpleCursorAdapter adapter;
String[] columns = {"Image", "ImageDate", "_id"};
query = new TableImages(this);
queryString = query.getData("images", columns, null, null, null, null, "ImageDate", "DESC");
int to[] = {R.id._id1, R.id._id2};
adapter = new SimpleCursorAdapter(this, R.layout.imagelist, queryString, columns, to);
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(adapter);
g.setOnItemClickListener(this);
try {
query.destroy();
} catch (Throwable e) {
e.printStackTrace();
}
}
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(ViewAllImages.this, ImageViewer.class);
Bundle b = new Bundle();
//I want to be able to use this -> b.putString("image_path", Image);
b.putlong("id", id);
i.putExtras(b);
startActivity(i);
}
public void listimages(){
SimpleCursorAdapter适配器;
String[]columns={“Image”,“ImageDate”,“_id”};
查询=新的表格图像(此);
queryString=query.getData(“images”,columns,null,null,null,“ImageDate”,“DESC”);
int到[]={R.id.\u id1,R.id.\u id2};
adapter=new SimpleCursorAdapter(this,R.layout.imagelist,queryString,columns,to);
画廊g=(画廊)findViewById(R.id.Gallery);
g、 设置适配器(适配器);
g、 SetonicClickListener(本);
试一试{
query.destroy();
}捕获(可丢弃的e){
e、 printStackTrace();
}
}
public void onItemClick(AdapterView父对象、视图、整型位置、长id){
意图i=新意图(ViewAllImages.this、ImageViewer.class);
Bundle b=新Bundle();
//我希望能够使用这个->b.putString(“image\u path”,image);
b、 putlong(“id”,id);
i、 putExtras(b);
星触觉(i);
}
这会将ID传递给我的下一个活动,下一个活动会查询拉取该图像路径的DB。我仍然需要使用listview来显示图像,这会导致应用程序在手机上因内存使用而崩溃(图像太大)
我可以压缩图像,但我需要将路径作为字符串,如果不创建自定义内容提供程序或添加textview并使用gettext.toString,我就不知道如何压缩,而这只是getto。我的脑袋快累死我了,因为我所做的所有阅读和编码lol。我在谷歌和不同的论坛上搜索过,但我在寻找答案时遇到了问题
是否有方法使用现有查询并获取字符串或字符串数组作为结果
谢谢。我刚创建了一个自定义内容提供商。现在我的查询更加灵活