Programming Android: Create Icon with Text Using GridView and Layout Inflater

Featured

How to create Icon With text like home screen, here is my example screen:

Icon with Text Programming Android: Create Icon with Text Using GridView and Layout Inflater

To do something like this we need to use GridView and make The Icon with text using the XML layout and then using LayoutInflater to read the XML and put it into the Adapter. Lets begin with the icon.xml(we put it into /res/layout/) that will be the view to show ImageView and Text together.

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_x="201px"
android:layout_y="165px"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/icon_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<TextView
android:id="@+id/icon_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="center_horizontal"
android:textColorHighlight="#656565">
</TextView>
</LinearLayout>

Here we put the ImageView and TextView into Linear Layout. In line 7 and 8 we define how big is our icon with layout_x and layout_y. Thats all, this icon.xml file next we will use in the Adapter to fill in our GridView.

Lets go to our GridView XML. I name it main_switch.xml, this locate in /res/layout/.

<?xml version="1.0" encoding="utf-8"?>
<GridView
  xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/GridView01"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent"
    android:padding="10dp"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:numColumns="auto_fit"
    android:columnWidth="60dp"
    android:stretchMode="columnWidth"
    android:gravity="center">
</GridView>

In this XML file we define the main layout of our screen, and how will be the grid will be display. This will be load to our main Activity.

Lets go to our Activity Class

public class MainSwitch extends Activity{
	GridView grid_main;
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_switch);

		grid_main = (GridView)findViewById(R.id.GridView01);
		grid_main.setAdapter(new ImageAdapter(this));
	}
	public class ImageAdapter extends BaseAdapter{
		Context mContext;
		public static final int ACTIVITY_CREATE = 10;
		public ImageAdapter(Context c){
			mContext = c;
		}
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return 5;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			View v;
			if(convertView==null){
				LayoutInflater li = getLayoutInflater();
				v = li.inflate(R.layout.icon, null);
				TextView tv = (TextView)v.findViewById(R.id.icon_text);
				tv.setText("Profile "+position);
				ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
				iv.setImageResource(R.drawable.icon);

			}
			else
			{
				v = convertView;
			}
			return v;
		}
	}
}

Line 4 – line 10 : we overide onCreate() from the Activity class, here we setContentView() to main_switch.xml, get the GridView and then fill it with the ImageAdapter class that extend from BaseAdapter.

line 24-41 : we define the view that will display on the grid, we use LayoutInflater to get view from icon.xml file that we already define before. We also can manipulate both ImageView and TextView with what parameter that we want to set, for example we can set the text or change the ImageView Resource, etc.

line 18-21 : we set how many icon we want to display.

Android View:Plantronics M50 – Bluetooth Headset – Retail Packaging – Black

android view

I have owned many bluetooth headsets over the years so here is my opinion of the Plantronics M50 in comparison. First of all this headset can stream music or podcasts from your smart phone which none of my previous headsets could do. It also has built-in noise reduction to reduce or eliminate background noise like wind, rain, traffic or music. It has voice alerts that tell you the battery level, volume level, talk time and more. It has a special battery meter that will show up on your screen if you have an iPhone.

This headset syncs easily on my Samsung Gravity Touch or PS3 if you happen to play video games online. The sound quality is good for an average priced headset. I don’t have any problems with disconnects or voice transmission.

I have also owned other headsets that tend to want to move or feel like they are going to fall off.


Price : $49.99 $24.18
Usually ships in 24 hours
buynow big Android View:Plantronics M50   Bluetooth Headset   Retail Packaging   Black

Continue reading

Android Look :amPen (TM) Ultra-sensitive Capacitive Stylus For Apple IPad, IPad 2, IPad 3, IPad 4, IPad Mini, IPhone 4s, IPhone 5, Ipod, Galaxy S 3, Nexus 7 [in Retail Packing]

android sight

I received a Kindle Fire for Christmas and shortly after I bought a Samsung Android cellphone. I found that I preferred using a stylus when using texting and e-mail. I bought several less expensive styluses, a few of which the tip wore off after a month or so. I then found a stylus that was more expensive, pink and extended when using it, but when not it collapsed to a smaller size and had a string which on the end was a plug that plugged into the headset jack on both the Fire and cell. When I received it, I noticed that the rubber tip was a bit thinner than the cheaper styluses and within a couple of weeks the rubber tip came off completely.

An online “friend” suggested this stylus.


Price : $21.99 $6.95
Usually ships in 24 hours
buynow big Android Look
:amPen (TM) Ultra sensitive Capacitive Stylus For Apple IPad, IPad 2, IPad 3, IPad 4, IPad Mini, IPhone 4s, IPhone 5, Ipod, Galaxy S 3, Nexus 7 [in Retail Packing]

Continue reading

Samsung Smart Tv Stare:Samsung HW-E450 Wireless AirTrack Sound Bar

samsung smart tv look

I started looking at sound bars to replace my old Sony 5.1 system. I was tired of all the cables running everywhere and the space all that took up. It was also pretty complicated for my wife to figure out. I also was not very impressed with the sound for watching tv/movies. For music the 5.1 system was great. Now I do have to admit, movies on disc were great but those over the regular cable box were not.

I was scoping this out at Wal-Mart along with a few other options. I wasn’t planning on getting one this expensive but I’m glad I did. The sound is great and the features are awesome. Now with that said I have a Samsung TV and I can’t seem to get the audio sync thing to work. I can get the audio working with the TV remote and to power off together but not come on together. I’m sure some more time spent playing with it or calling tech support might yield a result but for now I just added the features of the original remote to my one for all remote.


Price : $299.99 Too low to display
Usually ships in 24 hours
buynow big Samsung Smart Tv Stare:Samsung HW E450 Wireless AirTrack Sound Bar

Continue reading

Samsung S4 Description :HTC EVO LTE 4G Android Phone (Sprint)

[wpgrabit]http://ecx.images-amazon.com/images/I/51bodej5JZL.jpg[-]samsung s4 picture
[-]samsung s4 picture
[-]samsung-s4-B007ZUN6GS[/wpgrabit]

I’m not your typical user, I tend to be very particular about little details that not everyone will care about, so I’ll try to only talk about these things in attempt to avoid saying what’s already been said in other reviews.

The Evo 4G LTE is not technically a part of the HTC One series found on AT&T, Verizon, and T-Mobile, but it has all of the same internals (including the screen) of the HTC One X on AT&T. What this has that the One X doesn’t have, though, is an empty microSD slot along with the 16GB internal storage, a dedicated camera shutter button, and an officially unlockable bootloader.

Yep, the Evo 4G LTE’s bootloader is unlockable by the official HTCdev method, (made easy by the folk at XDA Forums.) No hacks or exploits. You do get a warning from HTC saying that unlocking may void the Warranty in some situations, but if you’re an advanced android user looking to put different versions of Android on this phone, this will likely not be a concern for you. For new users looking to get a phone that’s unlocked easily and reliably, you’ll want to check this one out. I have a modified version of the stock ROM that ships with this phone. It has tweaks such as remapping the functions of the physical capacitive buttons. (Replacing the “App Switcher” button with the traditional “Menu” function allows you to free up more screen space since the “three dot” software menu button won’t be on the screen anymore. Then, remap the “App Switcher” function to the Back button when long-pressed. I find this as an ideal setup on an unlocked LTE.) If you root your LTE, I’d also suggest downloading Android Commander for your computer so you can easily edit system-level files such as unwanted Apps. I’d give the EVO LTE 5/5 stars if I never unlocked the bootloader for custom ROMS — but now that I have, I’d rate this phone something like 7/5 stars if I could. It’s going beyond my expectations.

Elsewhere, I have to say I’m absolutely drooling over the screen on this phone. I’m a digital artist, so I’m very perceptive of screen color casts and things.


Price : $729.99

buynow big Samsung S4 Description
:HTC EVO LTE 4G Android Phone (Sprint)

Continue reading

Samsung S3 Mini Idea :Anker® Astro3 10000mAh Multi-voltage 5V / 9V / 12V 2A External Battery Pack ( Dual USB Output Plus DC Output ) For Samsung Tablets, Netbook, Digital Cameras, DV Recorders, PS Vita, Nexus 7, NDS, NDSL, GoPro; Smart Phones, Android Phones: IPhone 5 (OEM CABLE REQUIRED), IPad, IPod; HTC Sensation, EVO, One X; Samsung Galaxy S3 [12 Connectors For Mobile Phones, 6 Connectors For Tablets, US AC Adapter Included]

samsung s3 mini description

I’m a professional photographer that does a lot of travel and location work and I frequently don’t have access to a secure power outlet. At first, I was hesitant to purchase this item since it’s from a company I was unfamiliar with. But after reading the reviews and visiting their website, I ended up buying it and I have to say I’m quite impressed. I initially wanted it as an emergency power pack to extend my iPhone 4S’ battery life and upon receiving it, it turns out that I can use it to charge many other pieces of gear as well. Overall, it’s a fantastic product.

It’s approximately the size of a typical portable USB hard drive and the build quality is quite solid.


Price : $0.00 $59.99
Usually ships in 24 hours
buynow big Samsung S3 Mini Idea
:Anker® Astro3 10000mAh Multi voltage 5V / 9V / 12V 2A External Battery Pack ( Dual USB Output Plus DC Output ) For Samsung Tablets, Netbook, Digital Cameras, DV Recorders, PS Vita, Nexus 7, NDS, NDSL, GoPro; Smart Phones, Android Phones: IPhone 5 (OEM CABLE REQUIRED), IPad, IPod; HTC Sensation, EVO, One X; Samsung Galaxy S3 [12 Connectors For Mobile Phones, 6 Connectors For Tablets, US AC Adapter Included]

Continue reading

Samsung S2 Illustration :Motorola H720 Bluetooth Headset – Motorola Retail Packaging

samsung s2 view

This is the BEST bluetooth I have ever owned.

I had the H710 before this, but my car was broken into and it was stolen. I immediately purchased the newest model of the same Motorola series – this H720 – and am thrilled with it.

First of all, this bluetooth does NOT stick INSIDE your ear. I can’t stand the bluetooths that do that. This unit has nothing to stick inside your ear. It is flat and lays flat against your ear. It is also loud and clear so you don’t have to worry that you’re giving up on sound.


Price : $75.23 Too low to display
Usually ships in 24 hours
buynow big Samsung S2 Illustration
:Motorola H720 Bluetooth Headset   Motorola Retail Packaging

Continue reading

Samsung S3 Picture :PowerGen Dual Port USB 2.1A 10W AC Travel Wall Charger For Apple IPad 2, New IPad 3, IPhone 5 4 4s 3Gs 3G, IPod Touch, And More Devices (USB Cable Not Included) – Black

samsung s3 description

Bought it a month ago for use with 3 Blackberries (rotation). Ports are marked NA and A. Assume NA means non-Apple. Blackberry charged on NA. Didn’t charge on A. Why? The data pair (2 pins) are shorted in the NA port. Many phones (many Blackberries) want to see this configuration from a wall charge unit. So what do you if you want to charge 2 Blackberries at once? You buy USB charging cables. What’s a USB charging cable? It’s a USB cable with the 2 data pins shorted out.
Whether we’re talking 1.0, 2.0 or 3.0, there are still two kinds of cables. The ones that ship with phones are called Data cables. For wall chargers, you’re better off with an honest to goodness charging cable. All the cables I’ve collected over the years came with phones. So they’re all data cables. Data cables don’t have the data pair shorted out. Charging cables do.


Price : $9.99
Usually ships in 24 hours
buynow big Samsung S3 Picture 
:PowerGen Dual Port USB 2.1A 10W AC Travel Wall Charger For Apple IPad 2, New IPad 3, IPhone 5 4 4s 3Gs 3G, IPod Touch, And More Devices (USB Cable Not Included)   Black

Continue reading