Pages

Tuesday 10 May 2011


  Android Configure with NetBeans : (http://wiki.netbeans.org/IntroAndroidDevNetBeans)
Step 1:
Netbeans ==>MeunBar==>Tools==>Plugins==>Settings(Tab)==>Click Add Button

 
2.Update Center Customizer
Name : nbandroid or any name…
3.Another Alternative Method for to add android Plugin .Just Download latest AndroidPlugin(.nbm files) from  http://kenai.com/projects/nbandroid/downloads
1.Tools==>Plugins==>Downloaded(Tab)==>Add plugins==>Browse The latest Android Plugin(.nbm files)==>Install
Step 2:
  1. Plugins==>Available Plugins(Tab)==>type Android in Search Box
  2. Then Click Android CheckBox ==>Install
 
 
Step 3:  
Netbeans==>File==>Open Project
Step 4:
1.Enter Project Name, Set Package Name
2.Android Platform hasn’t been Specified, So first set Android SDK Platform.
3.Click Mange Platform or ToolsèJava Platform
4.JavaPlatform Addplatform  
5.Select Google Android Handheld Platform
6.Browse Android SDK Loaction(E.g: D:\Software\Android\Android_SDK_2_2\Android SDK)
 7.Final Set Android Platform Name: Android or any Name….
8.If  you like add no of android platform on different names.
Step 5:
Sample Project List Download Link
New Project Structure Flow:
The file SearchListActivity.java is as shown below:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.me.list;
import android.app.Activity;
import android.os.Bundle;
/**
 *
 * @author Surendran
 */
public class SearchListActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        // ToDo add your GUI initialization code here  
       
    }
}
 An Android application is organized as a set of activities. The file SearchListActivity.java that has been generated is the searchlist activity class for this application.

Whenever run your android Appliction in Netbeans before just create  the  preferred AVD
Then run your application otherwise at the runtime you got server not found error
1.Select Android SDK Manager Loacation
2.Select Virtual Devices then create New Android Virtual Device
  1. Select whatever platform level you need maximum select low level because your App’s  run on old android devices
  1. Click Start for launch  Android Virtual device

Running your project
Now, build and Run your project as you would do with any other NetBeans project. Your project builds successfully and the Android emulator boots up: 
Where is our Hello World?
Just add
setContentView(R.layout.main);
to the above file in place of
// ToDo add your GUI initialization code here
This should have been generated by the plugin, because the main.xml containing the main view was generated.

Alternatively we can do the following.
We shall now add support to the skeleton code to display the text- Hello, Android. Add the following to the above file in place of the "// ToDo add your GUI initialization code here":
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
You will notice that the IDE complains- "Cannot find symbol". This is because we need to import the class TextView. Its easy with NetBeans. Just click on the yellow bulb and select "Add import for.."
The file should now look like:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.me.list;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 /**
 *
 * @author Surendran
 */
public class SearchListActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
       
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
//setContentView(R.layout.main);
//output:Hello Android from Netbeans
    }
}
Now, run the project again

Prevent Selection of Target on Each Run 
When you run your project you are given a dialog asking which android device or emulator you would like to use. This can get annoying after several compile/run iterations. To set a default target, right click on the project name, select Properties. Select Run. Click on Automatic and set the preferred AVD. If you do not set the preferred AVD, NetBeans will continue to ask you at each run instance.



No comments:

Post a Comment