How to create Link button in android - android-widget

I want to create Link button in android.
Can anyone guide me in how I can create a Link button in android?

Simple. Just put the link in your TextView.
<TextView
android:id="#+id/txtLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/about_link"
android:autoLink="all" />
Note: The most important property here is android:autoLink="all". This allow you to link to urls, emails and phone numbers.
In your strings.xml add the link:
<string name="about_link"><a href='http://example.com'>http://example.com</a></string>
<string name="about_email"><a href='mailto:admin#example.com'>admin#example.com</a></string>
I know this answer is coming really late, but hope it helps someone else coming along.

Uri uri = Uri.parse("http://www.example.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

Related

TextView blocking ListView onItemClickListener

I have simple list view with list items defined by following layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/list_item_selector" >
<TextView
android:id="#+id/menuItemTextView"
android:clickable="false"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#00000000"
android:padding="20dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/blue"
android:textIsSelectable="true" />
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingRight="10dp"
android:src="#drawable/arrow" />
> </RelativeLayout>
When I click TextView the listView.onItemClickListener is not called. The problem occurs on Android 4. Android 2.x is OK. Is there any trick to pass an event from TextView to its ListView without defining onClickListner on the TextView?
In your main activity just make you listview as focusable true. This worked for me. If you are using a custom list view the focus is passed to its childs and not the list so to get the focus back to listview use
listView.focusable(true);
and the other things as textview just set their focus as false.
It was the android:textIsSelectable="true" attribute. Don't follow lint hints blindly.
android:inputType="textMultiLine" can also cause this problem. If you've included that attribute in your TextView xml, try removing it.

Can any one point me to this "Take a picture" widget in google plus android app. Want to know how to create a UI of that type

Can any one help me out how how this widget can be developed as in attached.The widget in the attached is of "Take a photo" or select photo" UI. Just want to know how can we create this UI widget. Any tutorials/and discussions/reference would help.Thank You.
Use hierarchyviewer tool from Android SDK. I tried.
You can learn that this menu is a custom baked dialog or activity, created from FrameLayout, ScrollView, LinearLayout and Buttons.
So to make one, you'll have to roll your own in similar style.
Here is how the xml would look like. You'd have to have a background for the FrameLayout and also 2 for the buttons. One with a full rectangle and the other without the top line. Then some margins/paddings tweaking and you should be fine.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_gravity="center_vertical|center_horizontal">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" android:background="#444" android:textColor="#fff" android:layout_marginBottom="1dp"/>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" android:background="#444" android:textColor="#fff"/>
</LinearLayout>
</ScrollView>
</FrameLayout>
Note: this is based on Mice's answer.
I don't think its native android widget. May be you can find it on github try searching over there.
Use GreenDroid library, it has what you are looking for. It is a nice library with host of features. To test it download this sample application

flv img does not appear <fb:flv src="" ..... img='img url' ...>

I am developing a facebook application to show some flv videos.videos are shown but, the preview img does not appear this is my code:
<fb:flv src='http://mobimediaworld.com/flv/3.flv' width='180' height='150' title='Mekawy' color='#FFBB00' salign='r' img='http://www.gcmob.com/Images/Media/PreviewFrame/27.png' scale='showall'/>
can anybody help me, pleas?
Sorry buddy fb:flv not working anymore dont know why.
use this:
<fb:swf
swfbgcolor="000000"
imgstyle="border-width:3px; border-color:white;"
swfsrc='http://www.youtube.com/v/xxxxxxxxxx'
imgsrc='http://img.youtube.com/vi/xxxxxxxxxx/2.jpg'
width='340' height='270' />

Dynamically expanding widgets on Android UI

I'm trying to create a simple Android UI that consists of a EditText and Button widget. However I'm having some problems with setting the layout properties. The UI is supposed to look like this:
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒
Left is the EditText and right is the Button. The Button (ImageButton) has a widths of approximately 50x50 which I would like to be fixed. The TextBox however should span the entire free space up to the button but I am not able to get this working. I would like to have this work dynamically so I don't have to specify a different layout for different screen sizes or orientation (if this is possible at all).
This is my first Android app so I appreciate any suggestions on how to best build the UI for an application.
Thanks,
b3n
This should place the elements how you wanted.
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="text"/>
<Button
android:id="#+id/b1"
android:text="test"
android:layout_height="50px"
android:layout_width="50px"
/>

Android - Customizing the Spinner widget Look and Feel

Is it possible to change the color of the radio button in the Android spinner widget. By default it displays the green color for the radio button.
I need to change it to some other color, is it possible, and how?
I know this is an old question now, but here goes...
You will need to create a custom Theme and apply it to the Activity with your spinner.
First, you need to create images for the checked/unchecked states of the 'new' radio, you could just pull the given images btn_radio_on.png and btn_radio_off.png from the sdk's res/drawable-* folder(s). Edit them to look how you want (such as changing color or whatever) and save off to your project.
Next, create a new xml file in your res/values folder, and add the following:
<resources>
<style name="CustomSpinnerRadioTheme" parent="#android:style/Theme">
<item name="android:spinnerDropDownItemStyle">#style/EditedRadio</item>
</style>
<style name="EditedRadio" parent="#android:style/Widget.DropDownItem.Spinner">
<item name="android:checkMark">#drawable/edited_radio</item>
</style>
</resources>
Then, create another xml file in res/drawable named edited_radio.xml, and it should contain the following:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="#drawable/btn_radio_off" />
<item android:state_checked="true" android:drawable="#drawable/btn_radio_on" />
</selector>
just be sure to reference your edited images for the checked states. Then you just have to apply the CustomSpinnerRadioTheme to your Activity and run!
A good resource I found is Applying Styles and Themes especially the additional reference on Android Styles (styles.xml) and Android Themes (themes.xml)