Skip to main content

Posts

How to Create animated drawable.

This is simple example which rotate frame by frame , just you need to create each rotate image ans play one by one. http://developer.android.com/guide/topics/graphics/drawable-animation.html 1.Create animated drawable. <animation-list xmlns:android = " http://schemas.android.com/apk/res/android "     android:oneshot = "true" >     <item android:drawable = "@drawable/rocket_thrust1" android:duration = "200" />     <item android:drawable = "@drawable/rocket_thrust2" android:duration = "200" />     <item android:drawable = "@drawable/rocket_thrust3" android:duration = "200" /> </animation-list> 2. AnimationDrawable rocketAnimation ; public void onCreate ( Bundle savedInstanceState ) {   super . onCreate ( savedInstanceState );   setContentView ( R . layout . main );   ImageView rocketImage = ( ImageView ) findViewById ( R . id . rocket_ima...

Store array of String or int or list in SharedPreferences android

 SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences( this );         JSONArray arr = new JSONArray ();         arr.put( "Viren" );         arr.put( "Android" );         prefs.edit().putString( "key" , arr.toString());         prefs.edit().commit();         try {             arr = new JSONArray (prefs.getString( "key" , "{}" ));             System. out .println(arr.getString(1));          } catch ( JSONException e) {             e.printStackTrace();         }

ProgressDialog example using handler android

final ProgressDialog dialog = ProgressDialog . show ( this , "Title" , "Message" , true ); final Handler handler = new Handler () { public void handleMessage ( Message msg ) { dialog . dismiss (); } } ; Thread t = new Thread () { public void run () { // write process code here. handler . sendEmptyMessage ( 0 ); } } ; t . start ();

local image & text load in webview

public void onCreate ( Bundle savedInstanceState ) {         super . onCreate ( savedInstanceState );         setContentView ( R . layout . main );         WebView view = ( WebView ) findViewById ( R . id . webView1 );         try {         InputStream input = getResources (). openRawResource ( R . raw . lights );         Reader is = new BufferedReader (                 new InputStreamReader ( input , "windows-1252" ));             //InputStream input = getAssets().open("ws.TXT");             int size ;             size = input . available ();             byte [] buffer = new byte [ size ];             input . read ( buffer );     ...