Monday 30 December 2013

create a new package in android

hi guys today i am going to tell you how you can create a new package in android and resole the reference error in that package. we create a new package to keep over project in a organised manner so that if we want to change anything afterwords we don't have to search in the whole project. so lets start..... 

First step
right click on the src directory of your project and click on new package 


Second step
enter the package name like com.xxxx.xxx.xxx and click ok


Third step
now your new package will be created and now you have to create a new class file in that package




 








Fourth step
after doing this extend your class with activity and create oncreate function in that set the content view to any of the layout file. 

Fifth step

now save it you will see that the there is an error on R.layout.activity_main to remove this error remove the import android.R; 

and add 

import com.your.mainpackage.name.*;

or if it still shows the error create chage the above import statement to 

import com.your.mainpackage.name.R;





No comments:

Post a Comment