Monday, January 28, 2013

26 Create a simple File Explorer in Android


Many android apps need a File browser to help users work with files in their device. In this tutorial we going to create a simple File Explorer.

Here is a result of this tutorial:
Simple File Explorer Android

This project is developed in Eclipse 4.2.0.

1. Make application interface: The main layout of this app demo is very simple layout. It have one text view, one edit text and one button.

Tuesday, January 15, 2013

2 The Registered tutorial easily earn in Vagex dollars

Vagex introduced:  Register link: http://vagex.com/?ref=153811

Since the amount paid: US 10.00 
Payment method: PAYPAL / PAYZA (must be certified) 
Revenue model: there is a fluctuation in the exchange rate, the daily fluctuations, if you run time is about 1 USD / 14000 Points Referral: 10% 
Registered Address: Register Link Vagex
Vagex registered tutorial: 
Fill out the registration information: 
Vagex registered Tutorial - Figure 1

18 How to create custom ExpandableListView in Android


From Developer.android.com: “A view that shows items in a vertically scrolling two-level list. This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children. The items come from the ExpandableListAdapter associated with this view”

In this tutorial, we show you how to create a custom ExpandableListView with some images, texts... We want to make some groups of car and customize them with image, text and a checkbox. In each group, we will contain a few different cars, in particular each children row has to contain: an image and the name of the car.

Here is a result of this tutorial:

expandable list view example


This project is developed in Eclipse 4.2.0.

1. Make application interface: The main layout of this app demo have a text view, a button and an expandable list view.

Sunday, January 13, 2013

0 View youtube with vagex – make money free with vagex


Link to register: http://vagex.com/?ref=153811

What is vagex:

Vagex is a new version view exchannge site could expose videos to other members for increasing their view,Once you sign up as the member of vagex,you watch videos then you get views to be paid (Vagex could pay you by paypal or alertpay) or exchange other member’s views to your videos.
Link Register For Vagex.com

What is vagex viewer? How to make money with vagex?

Vagex’s viewer is the software to help you surf the youtube video to get credtis,You will earn 1 extra credit per view for each action.So you need to download the Vagex Viewer to earn more credits.
Viewer are divided into three versions (Windows Vagex Viewer, FireFox Viewer, Android Viewer)
vagex paid to view youtube video
Visit the page http://vagex.com/members/downloads.php : Download the latest version as you like.
vagex paid to view youtube video
vagex paid to view youtube video
Vagex soft auto view
Advice:
(1)You had better set up a new youtube account which must have been attached with a photo image.Then tick the four options( auto subscribe,auto comment,auto like,auto favourite) after you have saved your youtube account login information.
(2)If you have owned a linux vps,you can also run the firevag addons in the firefox.Within 20 days,earnings could reach more than 10 dolloars,then you can cash out happily.
So,wether your browser is Interneter elxplorer or firex forex,when you are using computer or smart phone,you can always start to earn credits instantly,and earn money automatically.
Notes:
If you have a vps could also leave some space to run the vagex viewers,you could earn many more. Especially if you have a windows vps,you just need to run the vagex view directly on the platform which has installed the net framework(version should be at least 2.0)
Other common ways to earn free credits with an ease:
  1. You could post your own vagex referral link on facebook page wall and earn 500 bonus credits. Post must be public – this is valid for one time everyday.
  2. You could earn an extra credit if you Auto-Like or if you Auto-Subscribe each video (must be logged in to work).
  3. You can create a short fresh and unique video and publish it on youtube channel(your referral link should be included in the description),this is just valid for one time per month.
  4. You can also post your referral link in your twitter,This is valid for every day by tweeting vagex  like below :
Tweet – Make Money watching Youtube videos,Tweet – Watch UTube vidz for $$$$ ,Tweet – Watch UTube vidz for cash,Tweet – Automatically view YouTube vids for cash
Conclusion:
Vagex is a good program you could make some dollars for fun while visiting videos,10 dollars per month is easy to be done,vagex minimum cashout is 10 dollars, especially if you have purchased the vps to run your websites,it will be a very good extra supplement to afford your vps. If you could earn 10 dollars with VPS automatically with vagex viewer,why not have a trial?
Received payment from vagex:
vagex paid to view youtube video
vagex paid to view youtube video
Vagex send money to paypal account
Source: http://www.vagex.org/view-youtube-with-vagex-make-money-free-with-vagex/

Wednesday, January 9, 2013

6 How to create custom Listview in Android

ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.

In this tutorial, we show you how to create a custom list view with some images, texts... We want to make a list view to store information about a list of foobal legend, in particular each row has to contain: an image of the legend, the name, the date of birth and the image of his nationality.

Here is a result of this tutorial:

Android Custom ListView example

This project is developed in Eclipse 4.2.0.

1. Make application interface: The main layout of this app demo have one text view and one list view.

Sunday, January 6, 2013

10 How to create custom progress bar and progress dialog in Android.


Progress Bar and Progress Dialog are useful to tell user that the task is takes longer time to finish. A Progress Dialog showing a progress indicator and an optional text message or view. Only a text message or a view can be used at the same time.
In this tutorial, we show you how to display a custom progress bar and use progress dialog in Asynctask to tell user that the file download task is running.

This project is developed in Eclipse 4.2.0.

1. Make main layout with some components: one button to show custom progress bars, one textview to show some infos, one button to start download image file from internet Url.

Thursday, January 3, 2013

2 How to create custom RatingBar in Android


A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in stars. The user can touch/drag or use arrow keys to set the rating when using the default size RatingBar.

In this tutorial, we show you how to create custom RatingBar and use it in Android.  

This project is developed in Eclipse 4.2.0.

1. Make main layout with some components.

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center">
        <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:text="Rate 5 star for RatingBar"  
            />
        <RatingBar
           android:layout_width="wrap_content"
           android:layout_height="50dp"
           android:layout_marginBottom="20dp"
           style="@style/StarRatingBar"
           android:id="@+id/ratingbar_default"
           />  
        <TextView
        android:id="@+id/textView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="show state up checkbox"
        android:textColor="#CC00CC"
        android:textSize="20dp"
        /> 
</LinearLayout> 

By default the RatingBar have 5 stars icon to set the rating value and the step size default is 0.5. These default can be change by add some android attributes in xml layout like:

        android:numStars="4"
        android:stepSize="1.0"

We custom RatingBar by define a new style for it

<resources>
    <style name="AppTheme" parent="android:Theme.Light" />
        <style name="StarRatingBar" parent="@android:style/Widget.RatingBar">
        <item name="android:progressDrawable">@drawable/star_rating_bar_full</item>
        <item name="android:minHeight">48dip</item>
        <item name="android:maxHeight">48dip</item>
    </style>
</resources>

Create star_rating_bar_full.xml in drawable folder

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+android:id/background"
          android:drawable="@drawable/star_ratingbar_full_empty" />
    <item android:id="@+android:id/secondaryProgress"
          android:drawable="@drawable/star_ratingbar_full_empty" />
    <item android:id="@+android:id/progress"
          android:drawable="@drawable/star_ratingbar_full_filled" />
</layer-list>

res/drawable/star_ratingbar_empty.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- This is the rating bar drawable that is used to
 show a filled star. -->
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
      android:state_window_focused="true"
      android:drawable="@drawable/star2" />
<item android:state_focused="true"
      android:state_window_focused="true"
      android:drawable="@drawable/star2" />
<item android:state_selected="true"
      android:state_window_focused="true"
      android:drawable="@drawable/star2" />
<item android:drawable="@drawable/star2" />
</selector>

res/drawable/star_ratingbar_fillled.xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
      android:state_window_focused="true"
      android:drawable="@drawable/star3" />
<item android:state_focused="true"
      android:state_window_focused="true"
      android:drawable="@drawable/star1" />
<item android:state_selected="true"
      android:state_window_focused="true"
      android:drawable="@drawable/star1" />
<item android:drawable="@drawable/star1" />
</selector>

2. Code

2.1. When User click on RatingBar the selected rating value will be displayed in the textview

ratingBar_default.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener(){
    @Override
    public void onRatingChanged(RatingBar ratingBar, float rating,
           boolean fromUser) {
           // TODO Auto-generated method stub
           text.setText("Rating: "+String.valueOf(rating));
}});

2.2. And if user clicks on the button, the value of RatingBar will set by 5 stars.

final Button button = (Button)findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {
       ratingBar_default.setRating(5);
       text.setText("Rating: "+String.valueOf(ratingBar_default.getRating())); 
     }
});

3.DEMO
3.1. Click on RatingBar

Android Custom RatingBar

3.2. Click on Button

Android Custom RatingBar
  
You can download all source code of this tutorial at here
Reference: http://kozyr.zydako.net/2010/05/23/pretty-ratingbar/

Wednesday, January 2, 2013

4 How to create custom Switch in Android


From Developer.android.com: “A Switch is a two-state toggle switch widget that can select between two options. The user may drag the "thumb" back and forth to choose the selected option, or simply tap to toggle as if it were a checkbox. The text property controls the text displayed in the label for the switch, whereas the off and on text controls the text on the thumb…”

In this tutorial, we show you how to customize a Switch, add a click listener and get the setOnCheckedChangeListener for this Switch. Use Switch to control with media volume and wifi on device.

This project is developed in Eclipse 4.2.0.
1. First, modify the main layout of app. Open “res/layout/main.xml” file, add two switches, few textviews and a button.
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center">
    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:text="Disable all switch"
        android:layout_marginBottom="15dp"
            android:onClick="button_click"/>
   
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
           
        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/switch1"
                android:layout_alignParentLeft="true"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="20dp"
                android:text="Media Volume"/>
            <Switch
                android:id="@+id/switch1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textOff="OFF"
                android:textOn="ON"
                android:layout_alignParentRight="true"
                android:layout_marginRight="20dp"
                android:onClick="onSwitchClicked"
                android:thumb="@drawable/switch_bg"
                android:track="@drawable/track_bg"
                android:layout_marginBottom="15dp" />  
               
            <TextView android:layout_below="@+id/switch1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/switch2"
                android:layout_alignParentLeft="true"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="20dp"
                android:text="Wifi"/>
            <Switch android:layout_below="@+id/switch1"
                android:id="@+id/switch2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textOff="OFF"
                android:textOn="ON"
                android:layout_alignParentRight="true"
                android:layout_marginRight="20dp"
                android:onClick="onSwitchClicked"
                android:thumb="@drawable/switch_bg"
                android:track="@drawable/track_bg"
                android:layout_marginBottom="15dp" />  
        </RelativeLayout>
        <TextView android:id="@+id/textView"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="27px"
                android:layout_marginTop="15dp"
                android:text="Show spinner choice"
                android:gravity="center"
                android:textColor="#CD2134" 
                android:textStyle="bold"  />
</LinearLayout>
Note two attribute of Switch below:
                android:thumb="@drawable/switch_bg"
                android:track="@drawable/track_bg"

We need two xml files “switch_bg.xml” and “track_bg.xml” in folder drawable to customize for all switches:
res/drawable/switch_bg:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:drawable="@drawable/enable" />
    <item android:state_pressed="true"  android:drawable="@drawable/press" />
    <item android:state_checked="true"  android:drawable="@drawable/check_on" />
    <item                               android:drawable="@drawable/enable" />
</selector>
res/drawable/track_bg:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:drawable="@drawable/track_disable" />
    <item                               android:drawable="@drawable/track_default" />
</selector>

2. CODE.
2.1. Add click listener to all Switches
Use  android:onClick attribute in the Switch  XML definition:
android:onClick="onSwitchClicked "

Within the activity that hosts this layout, the following method handles the click event for all switches, one switch for ON/OFF Media Volume, and one for ON/OFF Wifi on device.

public void onSwitchClicked(View view) {
        switch(view.getId()){
        case R.id.switch1:
                if(switch1.isChecked()) {
                textview.setText("Switch 1 check ON by click on it"); 
                audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
                        8, 0);
                }
                else {
                textview.setText("Switch 1 check OFF by click on it");
                audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
                        0, 0);
                }
                break;
            case R.id.switch2:
                        if(switch2.isChecked()) {
                        textview.setText("Switch 2 check ON by click on it");
                        wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
                        wifiManager.setWifiEnabled(true);
                        }
                else {
                        textview.setText("Switch 2 check OFF by click on it");
                        wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
                        wifiManager.setWifiEnabled(false);
                }
                        break;
                }
    }

2.2. How to get the setOnCheckedChangeListener for Switch. This method is executed when the User drag the thumb or click on the Switch, and then do similar with onClick method of this Switch

switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        // TODO Auto-generated method stub
            if (buttonView.isChecked()){
                textview.setText("Switch 1 check ON by drag thumb");
                audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 8, 0);                                  }
            else{
                textview.setText("Switch 1 check OFF by drag thumb");
                audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
            }
        }
});
       
switch2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        // TODO Auto-generated method stub
            if (buttonView.isChecked()){
                textview.setText("Switch 2 check ON by drag thumb");
                wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
                wifiManager.setWifiEnabled(true);
            }
            else{
                textview.setText("Switch 2 check OFF by drag thumb");
                wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
                        wifiManager.setWifiEnabled(false);
            }
        }
});

2.3. Finally, add button onClick method to enable or disable all Switches

public void button_click(View view){
        if(is_enable == true)
        {
                is_enable = false;
                button.setText("Enable all switch");
                        textview.setText("Switch is Disable by click on button");
        }
        else{
                is_enable = true;
                button.setText("Disable all switch");
                textview.setText("Switch is Enable by click on button");
        }
        switch1.setEnabled(is_enable);
        switch2.setEnabled(is_enable);
    }
Note: to work with wifi on device, you want to add some permission in AndroidManifest file
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>

3. DEMO
3.1. Run Application

Android Custom Switch Control

3.2. When click on Switch 1 to ON/OFF Media Volume of device

Android Custom Switch Control
  
3.3. When drag thumb on Switch 2 to ON/OF Wifi

Android Custom Switch Control

4.4. Click on button to Enable or Disable all Switches

Android Custom Switch Control

You can download all source codes of this tutorial from here
Reference: http://developer.android.com/reference/android/widget/Switch.html