Import import android.graphics.Bitmap; import android.widget.ImageView;
Implement Activity View screen; => Reference to Linear layout UI btnCaptureScreen.setOnClickListener(new public void onClick(View arg0) { screen.setDrawingCacheEnabled(false); screen.setDrawingCacheEnabled(true); bmScreen = screen.getDrawingCache(); showDialog(ID_SCREENDIALOG); }});
@Override protected Dialog onCreateDialog(int id) { // TODO Auto-generated method stub screenDialog = null; switch(id){ case (ID_SCREENDIALOG): screenDialog = new Dialog(this); screenDialog.setContentView(R.layout.dialog);
bmImage = (ImageView)screenDialog.findViewById(R.id.image); TextOut = (TextView)screenDialog.findViewById(R.id.textout); btnScreenDialog_OK = (Button)screenDialog.findViewById(R.id.okdialogbutt on); btnScreenDialog_OK.setOnClickListener(btnScreen Dialog_OKOnClickListener); } return screenDialog; }
@Override protected void onPrepareDialog(int id, Dialog dialog) { // TODO Auto-generated method stub switch(id){ case (ID_SCREENDIALOG): dialog.setTitle(“Captured Screen”); TextOut.setText(EditTextIn.getText().toString()); bmImage.setImageBitmap(bmScreen); break; }
private Button.OnClickListener btnScreenDialog_OKOnClickListener = new public void onClick(View arg0) { // TODO Auto-generated method stub screenDialog.dismiss(); }};
Layout <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Capture Screen" />
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Enter some text here which you will see on captured screen" /> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" />