본문 바로가기

모바일 프로그래밍/Android 프로그래밍

AutoCompleteTextView/styles.xml 관련

public class DSubMap extends Activity {

public static Activity ctx;

static AutoCompleteTextView StationName;

Button StationInputbtn;

static final String[] STATION = new String[]{"가능","가산디지털단지","간석","구일","금정","금천구청"

,"명학","총신대입구(이수)","평촌","한대앞","한성대입구","월드컵경기장"};

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);// 중요합니다. setContentView(View view); 나 layout/main.xml을 넣을 수있다는거

//기억해둡니시다.

StationName =(AutoCompleteTextView)findViewById(R.id.StationName);//findViewById로 가져왔습니다.

ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line, STATION);

StationInputbtn=(Button)this.findViewById(R.id.StationInputbtn);

StationName.setAdapter(adapter);

StationName.setText("");

}

}

그리고 재가 3일정도 헤맨 내용이 있는데...

values/styles.xml 에 보면

<style name="AppTheme" parent="android:Theme.Light" />

라 나와있습니다.

<style name="AppTheme" parent="android:Theme.Black" />

이렇게 바꿔줍니다.

한번 예뮬레이터에 어플을 올려보시며 아시겠지만... 이 문제때문에 자동완성되는 글자가 안보여지는 경우가 있더군요.

Theme 관련 블로그 소개합니다.

http://blog.naver.com/jolangma?Redirect=Log&logNo=150086283752

여기 들어가시면 전체화면 이런거 잘나와있습니다.

다시 main.xml로 들어가 봅니다.

RelativeLayout 이라 나와있는데 LinearLayout으로 바꿔줍니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

 <LinearLayout

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:orientation="horizontal" >

<AutoCompleteTextView

            android:id="@+id/StationName"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="4"

            android:completionThreshold="1"

            android:dropDownSelector="@color/hint_color"

            android:hint="@string/stationhint"

            android:shadowColor="@color/hint_color"

            android:textColor="@color/black_s"

            android:textColorHint="@color/hint_color"

            android:visibility="visible" >

</AutoCompleteTextView>

 <Button

            android:id="@+id/StationInputbtn"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="@string/stationsearch" />

   </LinearLayout>

</LinearLayout>