how to make my own home screen for android?

How do I easily create an image/button on my Android home screen which links to a website?

  • I know the below example is of a custom home screen app, much like , but I'd just like to place custom designed buttons (like the "Attractions" button in the image below) or images on my personal mobile phone's home screen which links to websites that I specify links to. Is there an easy way to do that?

  • Answer:

    Disclaimer : This answer is only valid, if you're finding a way out to create this kind of layout in an application that you're building. This answer is not for the case where you want to create a widget on your own device which links to a website . I would give you an overview of the whole process and then you should write the code for yourself , for that would help you . But everything you will need to write that piece of code is given here, follow your instincts. Approach 1: In Your XML File: 1. Create a Grid View, you can customize as to which row can have how many tiles, their width height and params. 2. Create a Button for each tile and set params as wrap content for both of them. you can / should also set layout_gravity to align the buttons 3. Give unique id to each buttons using android:id="@+id/button1" [Do not use button1 as an id, it's bad coding convention, instead use android:id="@+id/attractions", I have given a general example.] In your Activity(Java) File : 4. Find the id to your buttons by using Button attractionsBtn = (Button) findViewById(Rhttp://R.id.button1)  , this goes in the onCreateMethod of your Activity. 5. Add an onClickListener this attractionsBtn . 6. Once you have added the onClickListener, you should now create a second Activity which will have a webview in it's xml file  and inside the onClickListener you should write an Intent to go the second activity. Go to the Second Activity: 7. Find the id for the webview similarly as you did for Button, and then use can use the loadUrl method on the webview and go to the website you want to . Note: If the website has java script code then you might also want to enable the javascrpt in your webview. For Ex: WebView myWebView = (WebView) findViewById(Rhttp://R.id.webview); myWebView.getSettings().setJavascriptEnabled(true); That's it and you're done. Approach 2: If you don't want to use Grid View, you will have to use Relative Layout's, in that case you will have to create a parent Relative Layout for containing other layouts Once the Parent Relative Layout is created , you will have to create other Relative/Linear Layout inside that containing two buttons for each row. But the rest of the process will be the same :) hope this helps !

Sudhanshu Bhatt at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.