288
No
AutoActivity
package com.example.choi.ex02;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;
public class AutoActivity extends AppCompatActivity {
//1.변수선언
TextView txtResult;
AutoCompleteTextView auto1;
String[] items={"java", "java1", "java2", "java3",
"c", "c++", "visual c++", "android", "apple"
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto);
txtResult=(TextView)findViewById(R.id.txtResult);
auto1=(AutoCompleteTextView)findViewById(R.id.auto1);
//2. 객체생성
//3. 아답터 생성
//4. 이벤트 처리
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items);
auto1.setAdapter(adapter);
}
}
activity_auto.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.choi.ex02.AutoActivity">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtResult" />
<!--android:completionThreshold="1" 도움말 제공 글자수-->
<AutoCompleteTextView
android:text=""
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/auto1"
android:layout_below="@+id/txtResult"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="26dp"
android:completionThreshold="1"
/>
</RelativeLayout>
댓글 ( 4)
댓글 남기기