Powered by Blogger.

Followers

Sunday, 14 July 2013

package com.sked.imagexml;

import java.io.InputStream;
import java.net.URL;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.Menu;
import android.webkit.WebView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView img;
 img=(WebView)findViewById(R.id.imgview);

         //  Drawable drawable = LoadImageFromWebOperations("http://" +
 // "192.168.42.122/res_ras/paneer.gif");
                 //img.setVideoPath("http://" +
         //"192.168.42.122/res_ras/run.mp4");
        //img.setImageDrawable(drawable);

        img.requestFocus();
        //img.getSettings().setBuiltInZoomControls(true);
        img.getSettings().getJavaScriptEnabled();
        img.setBackgroundColor(Color.BLACK);
        img.loadUrl("http://i1213.photobucket.com/albums/cc461/Amin555/th_a945663881350affda170b9fa8053437.gif");
        //img.start();
      //TextView tv= (TextView)findViewById(R.id.hello);
       //tv.setText("hello");
     
}

@SuppressWarnings("unused")
private Drawable LoadImageFromWebOperations(String url) {
// TODO Auto-generated method stub
try{
  InputStream is = (InputStream) new URL(url).getContent();
  Drawable d = Drawable.createFromStream(is, "src name");
  return d;
  }catch (Exception e) {
  System.out.println("Exc="+e);
  return null;
  }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

}


here is xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    
    tools:context=".MainActivity"
    android:background="#000000" >

    <WebView
        android:id="@+id/imgview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:layout_gravity="center" >
    </WebView>

</LinearLayout>

0 comments:

Post a Comment

Site search