我是新来的机器人,请容忍我缺乏知识。 我的应用程序正在拍照并将它们保存到位图ArrayList,它的工作原理,我测试它,照片可以使用ImageViews显示。一切负责拍照看起来是这样的:使用位图ArrayList动态填充ListView
//declaration
List<Bitmap> bmpList = new ArrayList<Bitmap>();
//onClick method of button for takin pics
public void takePic(View view){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode == 0){
Bitmap image = (Bitmap) data.getExtras().get("data");
bmpList.add(image);
adapter.notifyDataSetChanged(); //more about my adapter and stuff below
}
}
我也有ListView控件,我扩展ListActivity而不是只活动becouse我发现在网络动态字符串的ArrayList是工作液。 ListView控件的XML声明:(与方法我没有宣布它在Java代码中)
<ListView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/photoButton"
android:id="@android:id/list">
</ListView>
我还使用位图适配器:
ArrayAdapter<Bitmap> adapter;
,并对其进行初始化onCreate方法内:
adapter = new ArrayAdapter<Bitmap>(this, R.layout.item, bmpList);
setListAdapter(adapter);
item.xml是我有的问题。我不知道如何创建包含ImageView的工作ListView项目,该项目能够最好在左侧显示我的Bitmap ArrayList元素。我试图添加一个ImageView,但保存照片后应用程序崩溃。我的前往功能是在左边有照片,中间是简短描述,右边是评级栏,点击项目会将用户带到另一个活动,在那里可以修改描述和评分,同时也可以显示全尺寸的照片。某种暗示会很长一段时间!先谢谢你!
我有一些麻烦创建自定义适配器,以便它可以处理位图ArrayList – tomiQrsd 2015-03-19 12:32:45
您可能会发现有用的相关答案 - [this](http://stackoverflow.com/questions/5070830/populating-a-listview- using-arraylist?rq = 1)和[this](http://stackoverflow.com/questions/157944/create-arraylist-arraylistt-from-array-t?rq=1)。如果没有帮助,在这里发帖,你有什么麻烦。 – VadymVL 2015-03-19 12:35:34
谢谢,我设法创建了自定义适配器 – tomiQrsd 2015-03-19 22:39:48