Thursday, 12 May 2016

What is thread in java.

Thread:

1) Every Executable programme is called as thread.
2) we can achieve thread by two way.



   A)    By extending Thread class

      eg.
class ThreadDemo extends Thread{
public void run(){
System.out.println("Thread class extended");
}
public static void main(String[] args ){
ThreadDemo TD=new ThreadDemo ();
TD.start();
}
}


  B)    By implementing Runnable method.


       class ThreadDemo implements Runnable{

public void run(){
System.out.println("Runnable class Implement");
}
public static void main(String[] args ){
ThreadDemo TD=new ThreadDemo ();
TD.start();
}
}

Which is best thread.

If we extends Thread class then we can not extend another class. And if we implement Runnable interface and in future if we want to extend any class then we can extend if we implement Runnable interface.







Saturday, 23 April 2016

Exceptio error in android .gradle\caches\2.8\scripts\asLocalRepo37_tkshoj2mzpxt53d89bsykdde\cp_init\cache.properties (The system cannot find the file specified)

0pen c drive>user>uour user like your system name XYZ>.gradle>caches>2.8>script delete this folder and rebuild project

when i create fragment then it overlap on action bar

When you facing problem your action bar is getting overlapped by other activity.

Because you using frame layout add the following line in frame layout.

android:layout_marginTop="?attr/actionBarSize"


Like this it will resolve the problem of action bar overlapped actionbar.
in app_bar_main.xml
<FrameLayout    android:layout_width="match_parent"    android:layout_marginTop="?attr/actionBarSize"
android:layout_height="match_parent">  

Thursday, 21 April 2016

how to create list view in android

1. Create Dispay.java class
package com.example.ListDisplay;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListDisplay extends Activity {
   // Array of strings...
   String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu","Windows7","Max OS X"};
   
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      
      ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview, mobileArray);
      
      ListView listView = (ListView) findViewById(R.id.mobile_list);
      listView.setAdapter(adapter);
   }
}

2. now create one xml file activity_main.xml
 xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   tools:context=".ListActivity" >

   
      android:id="@+id/mobile_list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" >
   
 

3. Add following code in string file
xml version="1.0" encoding="utf-8"?>

    name="app_name">ListDisplay
    name="action_settings">Settings
4. create list item activity_listview
xml version="1.0" encoding="utf-8"?>


 xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/label"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:padding="10dip"
   android:textSize="16dip"
   android:textStyle="bold" >
List View

Wednesday, 20 April 2016

What is intent in android.

An android Intent is an abstract description of an operation to be perform.It can be use with start activity to launch an activity, broadcastIntent so send it to any interested Broadcastreceiver  component.and startService(intent) or bindservice(intent,ServiceConnection,int) to communicate with a background Service.