开发者

How to make multiple homescreens in an android app?

开发者 https://www.devze.com 2023-03-19 21:19 出处:网络
In my app i have 10 buttons on the opening screen , that is , the main screen. I want to distribut开发者_如何学JAVAe these buttons on different screens in the same app. In other words, i want to make

In my app i have 10 buttons on the opening screen , that is , the main screen. I want to distribut开发者_如何学JAVAe these buttons on different screens in the same app. In other words, i want to make three homescreens in my app and have buttons on them for three different types of tasks. just like we have homescreens in the mobile UI, i want to make them in my app just when it is opened. the three screens should be accessible by just touching the screen and holding it and moving it right or left. Does anyone know how this is done.


You could put three different views in a viewflipper, see http://developer.android.com/reference/android/widget/ViewFlipper.html, and then trigger the flipping with a gesture detector, http://developer.android.com/reference/android/view/GestureDetector.html


Start normally by navigating to File–>New–>Project–>Android Project. In package explorer you can find your all projects in workspace. Select your current project to view its hierarchy. Open res folder and select layout folder. You will find main.xml already there by default which is the user interface or layout of the application. To create another layout, Right click on layout folder and Go to New–>Other–>Android XML file. Give a name and another layout file(xml) file will be created alongwith main.xml. You can design this new xml file as you design main.xml.

Now this newly created layout or user interface can be used in two ways. These are:

In the same class itself by using the following syntax:

setContentView(R.layout.ms1); //where ms1 is the name of new layout

For sample code for the project you can visit my website article.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号