Android :: How To Create Button With Icon And Text?
Aug 27, 2009How can I create a Button with icon and text?
View 7 RepliesHow can I create a Button with icon and text?
View 7 RepliesI want to create a layout in such a way that on top edittext and button should be there in one row. The search text I enter in editext and click on search button. Then I want to display a custom list view where each row contains image and text.(As per the API demos example list14 I have tried). But when I run the application, button and edittext are being added to each row (i.e., Each row contains a image, text, editext, button.
Below is my xml file:
<!--
<FrameLayout android:layout_width="wrap_content"
android:layout_height="0dip" android:layout_weight="1"></FrameLayout>
-->
<ImageView android:id="@+id/icon" android:layout_width="48dip"
android:layout_height="48dip" />
<TextView android:id="@+id/text" android:layout_gravity="center_vertical"
android:layout_width="0dip" android:layout_weight="1.0"
android:layout_height="wrap_content" />
<!--
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/prdsearchtb"
android:text="@string/tb_prd_search_lbl"></EditText>
-->
<!--
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"> <TableRow>
-->
<Button android:id="@+id/prdsrcbutton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/btn_lbl_prd_search"
android:layout_x="2px" android:layout_y="410px"></Button>
<!-- </TableRow>
</TableLayout>
-->
and Java File:
/**
*
*/
package org.techdata.activity;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
/**
* @author jayanthg
*
*/
public class ProductSearch extends ListActivity {
private static class ProductSearchAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Bitmap mIcon1; private Bitmap mIcon2;
public ProductSearchAdapter(Context context) {
mInflater = LayoutInflater.from(context);
// Icons bound to the rows.
mIcon1 = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon48x48_1);
mIcon2 = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon48x48_2);
} @Override public int getCount() { return DATA.length;
} @Override public Object getItem(int position) { return position;
} @Override public long getItemId(int position) { return position;
} @Override public View getView(final int position, View convertView,
ViewGroup parent) { ViewHolder holder; Button btn=null;
if (convertView == null) { convertView = mInflater.inflate(R.layout.productsearch, null);
// Creates a ViewHolder and store references to the two children
// views // we want to bind data to. holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
btn=(Button)convertView.findViewById(R.id.prdsrcbutton);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView. holder = (ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
holder.text.setText(DATA[position]);
holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2);
holder.icon.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Log.i("image", " u clicked on icon Position" + position);
} } );
holder.text.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Log.i("Text", " u clicked on text Position" + position);
} } );
btn.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Log.i("Button","U clicked on button");
} } ); return convertView;
} static class ViewHolder { TextView text; ImageView icon;
} private static final String[] DATA = ListView product_search_list;
Button srch_btn;
EditText srch_text; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ProductSearchAdapter(this));
// setContentView(R.layout.productsearch);
// getListView().setEmptyView(findViewById(R.id.text));
// srch_text = (EditText)findViewById(R.id.prdsearchtb);
// srch_btn = (Button) findViewById(R.id.prdsearchtb);
// srch_btn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// callProductSearchAdapter();
// }
// });
} void callProductSearchAdapter() { setListAdapter(new ProductSearchAdapter(this));
} private void createDialog(String title, String text, final Intent i) {
if (i == null) { AlertDialog ad = new AlertDialog.Builder(this).setIcon(
R.drawable.alert_dialog_icon).setPositiveButton("Ok", null)
.setTitle(title).setMessage(text).create();
ad.show();
} } }
Do I need to create a new activity to view text written in a text box?
For example,
I want to see - "Hello"+ text written in a text box.
I wanted to create a notification without the icon in the status bar (the state that is not expanded). I tried the custom expanded view and set the icon for this view only. But it did not work. When I give 0 as icon to the constructor, the icon disappears but notification also does not appear in the expanded view.
Notification notification = new Notification(0, "", 0); I tried a lot of combinations but didn't come out with a solution. By the way, I know it is working because I saw this feature in some apps. Thanks.
Notification and NotificationManager are used to create icons to be placed on the top-left position of the screen. A Notification also need to have an entry on the status bar pull-down.
However, icons on the right side such as the battery, signal strength, wireless indicators do not need any entry on the status bar.
How do I make such icons without any entry in the status bar pull-down?
I am very new to programming and would like to know what is the best way to go about creating a notification icon badge similar to the ones on the iPhone apps. This would be basically for creating a badge for the notifications that end up in the notification bar.
View 2 Replies View RelatedI would like to have icon created on home screen through an activity . All the icons of my activities are on main menu, once i click it my activity will be launched instead i need an icon on home screen which when clicked activity should be launched.
View 4 Replies View RelatedCan you please tell me how can I create an android menu item using android setting icon?
View 1 Replies View RelatedAnybody can tell me how to create icon for existing application on Android
View 2 Replies View RelatedI thought this would be easy to find:
A text editor that can create/edit text files from the SD card.
i.e. Windows Notepad on the Desire?
I have placed an icon on the status bar. I would like to run a method of another class whenever the user selects that icon. I've seen similar functionality used in volume icons that sit on the status bar that allow a user to raise or lower the volume when the icon is clicked. However, these icons are on the right side of the status bar, and from what I've seen, I'm not allowed to put an icon there. I don't know if that kind of functionality is available to left side icons. So basically, I'm looking for how to run a function when a status bar icon is clicked. I don't want to open an activity, I just want to run a function.
View 1 Replies View RelatedI was wondering if it is possible to customize the icon used for the More menu option (displayed when there are more than 6 menu options)? With the stock vanilla Android UI it appears as a disclosure-type arrow and on HTC Sense UI it's an ellipsis icon. Curious if these are fixed icons only defined in the Android resources or if there is a way to programmatically set them?
View 1 Replies View RelatedI need to display progress icon in button so that user can interact other GUI elements while background task is processing. I have searched in Android developer site and found that we can use animated drawables but don't know how to use them.
View 1 Replies View Relatedhow to create an icon pack in .apk installable on apex or nova launcher?
View 2 Replies View RelatedI am wanting to allow the user of my android application the ability to set some parameters. The radio button is ideal for this situation. However, I don't like the radio buttons are rendered. Is it possible to change the radio button icon? For example, is it possible to create a custom layout for each row and in that layout reference my own icon and change the font et al.
View 1 Replies View RelatedI wounder how it's possible to create a bottom bar buttons in android. I read something about this UI solution, are there any controls that can be used?
View 2 Replies View RelatedI wish to create a button like a Equalizer Button. At the time of track the button i need to do some work.
View 1 Replies View RelatedI want to create a Button otherthan creating it from xml layout.i want to create the button in java class otherthan using any resources folder .please anyone help me to solve this
View 1 Replies View RelatedOn the G1 camera app, there's a handsome looking camera button which you can press to signal the app to take the picture. It's a round button with a little camera icon in it. Is that button resource available in android.R? I'd like to use it in my own app if possible?
View 2 Replies View RelatedI am running kaosfroyo with the AWD launcher. I accidently dragged an icon over the launcher bar and now my call button is gone. I have no idea how to get this back. The only thing about this I found on the site was the exact same question with no replies. does anyone know how to get it back. I tried to reset awd to defaults and that did not do it.
View 1 Replies View RelatedHow does one create an auto-repeat Button on Android.But it seems kind of heavyweight and clumsy.Is there a better way? (One would think that this would be a built-in capability like it is on most other UIs.)
View 5 Replies View RelatedI would like to create a button with circular or rectangular background, text and an image below or above the text.I would like to create a CustomButton object with methods setText() and setImage() which would change the button text and image and place multiple CustomButtons into main layout.Does anyone know how to create a custom layout, place it into another layout(main) and modify its elements from the activity which is bound to main layout?
View 2 Replies View RelatedI am trying to create one custom button which is circular and when i click that button i want that button FOCUS and COLOR change and i don't know how to do exactly so any one can help me or show me that code how to do?
View 2 Replies View RelatedI want to create a custom field on which I can place more than one line of text as well as images.
And the field can be used like a button(onclick event etc.)
I have an array of buttons. (calendar) now i know i set the background with a drawable. fine. but HOW can i create a image (best a nine png (so its stretchable) lets say with 3 rows each a different color) and finaly set it as a drawable? a short demo would be great
1. create simple image (3 rows with different color)
2. assign this image to a button
You need to have Internet permission. Instead of using thewebview, you are better off using the Bowser activity for this.
View 8 Replies View RelatedI want to create a circular button having a plus and minus sign on to this and exactly used in Android
Contacts application like shown in the image as below.
Is there anyway to create an icon on the actual program list called "Games" for example and containing all the g sames Ive downloaded. Ive used apps organizer to label my games as games!
View 6 Replies View RelatedWould make a Windows Software or tool to make an Icon Pack if it is provided with Images or even .png Icon files....... just creating the general xml n all files .......
View 1 Replies View RelatedHow do you create a button in an Android app that produces the same result as hitting the down key on the D-Pad?
View 1 Replies View Related