Created
May 13, 2017 13:22
-
-
Save bigkiandi/2362d51211e7b4db500ff622d46a7a6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Android.App; | |
using Android.Content; | |
using Android.Runtime; | |
using Android.Views; | |
using Android.Widget; | |
using Android.OS; | |
namespace AutoComplete | |
{ | |
[Activity(Label = "AutoComplete", MainLauncher = true, Icon = "@drawable/icon")] | |
public class MainActivity : Activity | |
{ | |
AutoCompleteTextView autocomplete1; | |
Button btn_Submit; | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); | |
// Set our view from the "main" layout resource | |
SetContentView(Resource.Layout.Main); | |
autocomplete1 = FindViewById<AutoCompleteTextView>(Resource.Id.autoComplete1); | |
btn_Submit = FindViewById<Button>(Resource.Id.btn_Submit); | |
var kota = new string[] { "Makassar", "Balikpapan", "Jakarta", "Jogja", "Surabaya", "Ambon", "Medan" }; | |
ArrayAdapter adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, kota); | |
autocomplete1.Adapter = adapter; | |
btn_Submit.Click += Btn_Submit_Click; | |
} | |
private void Btn_Submit_Click(object sender, EventArgs e) | |
{ | |
if (autocomplete1.Text!="") | |
{ | |
Toast.MakeText(this, "Kota dimasukkan =" + autocomplete1.Text, ToastLength.Short).Show(); | |
} | |
else | |
{ | |
Toast.MakeText(this, "silahkan masukan nama kota dulu", ToastLength.Short).Show(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment