Tuesday, 26 November 2013

Auto-complete Text view in android.

0 comments
In this post we look into the auto complete text view and how it will be used in your app.

Steps 1)Include the Auto-complete Text-view in your XML as following:-

<AutoCompleteTextView
                    android:id="@+id/txt_autoview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:text=""
                    android:textColor="#000000"
   />

Steps 2)Implements an interface as following:-

public class Depots extends Activity implements TextWatcher {

AutoCompleteTextView  txt_market;
List<String> market;

}

Steps 3)Add the following in your onCreate():-

market = new ArrayList<String>();
txt_market = (AutoCompleteTextView) findViewById(R.id.txt_autoview);

//Before you setting an adapter to the textview you have to add an items to the arraylist.

txt_market.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, market));


Steps 4)Add the Unimplemented methods for your Text Watcher interface.


Thanks..
Read full post »

Thursday, 14 November 2013

How To Change Modes Of Phone(Normal,Silent,vibrate) Programmatically.

0 comments
Today we have seen how to change the modes of phone using audio manager in Android.

1)Declare the Audio manager class.

   AudioManager am;

   am= (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);

2)Next, we have to perform an action on particular button to change the mode.

   @Override
   public void onClick(View view) {

        switch (view.getId())
        {

   //For Normal Mode
            case R.id.btn_normal:

                         am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
            break;

   //For Silent Mode
            case R.id.btn_silent:

                        am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
            break;

   //For Vibrate Mode
            case R.id.btn_dnd:
          
                      am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
          break;
      }
 }

Thanks..
Read full post »
 

Copyright © Unique Android Tutorial.. Design by Free CSS Templates | Blogger Theme by BTDesigner | Powered by Blogger