The first semester of junior high, the subject of secure communication and encrypted transmission between mobile phones
In this example, the function of selecting and displaying images on the SD card is simple, free, and easy to use.
// Picactivity. Java
Package COM. test. PIC. selected; import Java. io. filenotfoundexception; import android. app. activity; import android. content. contentresolver; import android. content. intent; import android. graphics. bitmap; import android. graphics. bitmapfactory; import android.net. uri; import android. OS. bundle; import android. util. log; import android. view. view; import android. widget. button; import android. widget. imageview; import android. widget. textview; public class picactivity extends activity {/** called when the activity is first created. * // @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); button = (button) findviewbyid (R. id. b01); button. settext (R. string. scan); button. setonclicklistener (New button. onclicklistener () {@ override public void onclick (view v) {intent = new intent ();/* enable pictures to set the image type to image */intent. settype ("image/*");/* use intent. action_get_content this action */intent. setaction (intent. action_get_content);/* returns the current screen after obtaining the photo */startactivityforresult (intent, 1) ;}}@ override // rewrite onactivityresult () function, used to pass the value protected void onactivityresult (INT requestcode, int resultcode, intent data) {If (resultcode = result_ OK) {URI uri = data. getdata (); textview Tx = (textview) findviewbyid (R. id. path); Tx. settext (URI. tostring (); // you can print the file path log of the selected image. E ("Uri", Uri. tostring (); contentresolver Cr = This. getcontentresolver (); try {Bitmap bitmap = bitmapfactory. decodestream (Cr. openinputstream (URI); // obtain the image information from the input stream. imageview = (imageview) findviewbyid (R. id. iv01);/* Set bitmap to imageview */imageview. setimagebitmap (Bitmap); // display the image to the control} catch (filenotfoundexception e) {log. E ("exception", E. getmessage (), e) ;}} super. onactivityresult (requestcode, resultcode, data );}}
I used the imageview layout control here, but I am not very familiar with it, but vaguely think it is very intelligent.
// Main. xml
<ImageView android:id="@+id/iv01" android:layout_width="fill_parent" android:layout_height="wrap_content" />
Everything is precious.
Looking back at my more than 20 years of life, so far, what kind of things have I always insisted on?
The same is true for your work. The first customer is not satisfied with your creativity, the second customer is not gorgeous, and the third customer thinks that the theme of his activity is not consistent.
The second blow left you physically and mentally exhausted and lost confidence.
Yes, none of the first three customers can see it, but what about the fourth one ?? What about the fifth ?? There will always be a Bole waiting for me. chelaile will also be known...
Don't lose yourself!
There is no difficulty in the world, just for fear of people with a heart. insist that you always stick to your lips, rather than secretly hiding in your pockets.
One day, my customers will continue to give up on him with professional knowledge.
One day, I will be able to stand at the peak of the martial arts.
One day, when my teammates fall down one by one, I will resurrect them one by one and push the blood to Jing Qing and add 6*1200 + gorgeous numbers to reverse the war, you will see that the first biological change in 109 Yangshuo West Street is still a myth...
There is a dictionary that only persists and does not give up. Sell you