Download presentation
Presentation is loading. Please wait.
Published byIra Collins Modified over 8 years ago
2
Import import android.graphics.Bitmap; import android.widget.ImageView;
3
Implement Activity View screen; => Reference to Linear layout UI btnCaptureScreen.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { screen.setDrawingCacheEnabled(false); screen.setDrawingCacheEnabled(true); bmScreen = screen.getDrawingCache(); showDialog(ID_SCREENDIALOG); }});
4
@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);
5
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; }
6
@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; }
7
private Button.OnClickListener btnScreenDialog_OKOnClickListener = new Button.OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub screenDialog.dismiss(); }};
8
Layout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/screen" > <Button android:id="@+id/capturescreen" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Capture Screen" />
9
<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:id="@+id/textin" android:layout_width="fill_parent" android:layout_height="wrap_content" />
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.