1
我想将布局转换为位图。该布局包含Textview和Listview。文本视图显示在位图中,但Listview在绘图缓存中显示但不显示(显示为空)。这里是我的代码不能将列表视图转换为位图
Print.xml
<LinearLayout
android:id="@+id/screen_print1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tax_amnt"
android:layout_width="360dp"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Tax : $200" />
<ListView
android:id="@+id/item_listview1"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_gravity="center" />
</LinearLayout>
Print.java
LinearLayout screenshot = (LinearLayout) findViewById(R.id.screen_print1);
ListView items_display=(ListView)findViewById(R.id.item_listview1);
TextView tax_amount=(TextView)findViewById(R.id.tax_amnt);
tax_amount.setText("$5000");
ArrayList<HashMap<String, String>> bill_list1=OrderSummaryFragment.item_lists;
itl1 = new Itemlist(getApplicationContext(), bill_list1);
items_display.setAdapter(itl1);
screenshot.setDrawingCacheEnabled(true);
screenshot.buildDrawingCache();
Bitmap bm = screenshot.getDrawingCache();
screen_imageview.setImageBitmap(bm);
在setAdapter()调用之后立即调用'itl1.notifyDataSetChanged()',或者项目显示正确但不显示在绘图缓存中? – Guardanis
yes项目正在显示,但未显示在绘图缓存中。 –