Thursday, 12 May 2016

What is thread in java.

       Every executable program is called as thread. and there are two ways to create a thread :
1. By extending Thread class.
2. By implementing Runnable method.

Example of By extending Thread class :

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();
}
}

Example of 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">