Skip to content

Instantly share code, notes, and snippets.

@jesselima
Created May 28, 2018 11:14
Show Gist options
  • Save jesselima/56e038eabec00cb2de610a745c95fc7e to your computer and use it in GitHub Desktop.
Save jesselima/56e038eabec00cb2de610a745c95fc7e to your computer and use it in GitHub Desktop.
Simple auto-complete from array and get system language (i.e: "en")
package com.android.myapplication;
import android.content.Intent;
import android.content.res.Resources;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
String locale = Resources.getSystem().getConfiguration().locale.getLanguage();
Log.v("Language: ", locale);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, EVENTS);
AutoCompleteTextView textView = findViewById(R.id.countries_list);
textView.setAdapter(adapter);
}
private static final String[] EVENTS = new String[] {
"Salto em Altura", "Salto com Vara", "Salto em Distância", "Salto Triplo", "100m", "200m", "400m", "10000m", "110m com barreiras"
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment