android - Can I display a image in custom layout? -


i know can use below code display image in system layout, hope display image in custom layout, how can that? thanks!

public void onclick(view v) {                     // todo auto-generated method stub                     int id = v.getid();                     intent intent = new intent();                     intent.setaction(intent.action_view);                     intent.setdataandtype(uri.parse("file://" + arrpath[id]), "image/*");                     startactivityforresult(intent,forbrowse); }    <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="@drawable/border_ui"     android:orientation="vertical"     android:paddingtop="3dip" >      <imageview         android:id="@+id/imageview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_weight="1" />      <button         android:id="@+id/btnclose"         style="@style/mytextappearance"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:text="@string/myreturn" />  </linearlayout> 

if above resolutions not ok, try one, loads image tha page want:

string url = "file://" + arrpath[id]), "image/*"; bitmap bmp = fromurl(url); imgview.setimagebitmap(bmp); , write function:  public static bitmap fromurl(string src) {           try {             url url = new url(src);             httpurlconnection connection = (httpurlconnection) url                     .openconnection();             connection.setdoinput(true);             connection.connect();             inputstream input = connection.getinputstream();             bitmap mybitmap = bitmapfactory.decodestream(input);              return bitmap;          } catch (exception exception1) {             return null;         } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -