안드로이드 개발 질문/답변
(글 수 45,052)
RelativeLayout안에 TextView가 있는데..
여기다 TextView의 속성으로
android:ellipsize="marquee"로 주고 setSelected를 true로 주고 싶은데
이 setSelected의 값을 어떠한 방법으로 줘야하는지 모르겠습니다.
xml상에서 setSelected의 값을 true로 주는 방법은 없는것입니까?? 없다면 메인쪽에서라도 설정하는 방법을 알고싶습니다.
xml문서..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:layout_height="168dip"
android:focusable="true"
android:paddingLeft="8dip"
android:paddingRight="8dip"
style="@style/WidgetBackground" >
<TextView
android:id="@+id/word_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dip"
android:includeFontPadding="false"
android:singleLine="true"
android:ellipsize="end"
style="@style/Text.WordTitle"/>
<TextView "marquee" 가 적용되어야 할 부분.
android:id="@+id/word_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_below="@id/word_title"
style="@style/Text.WordType" />
<TextView
android:id="@+id/bullet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:maxLines="7"
android:layout_below="@id/word_type"
style="@style/Text.BulletPoint" />
</RelativeLayout>
여기다 TextView의 속성으로
android:ellipsize="marquee"로 주고 setSelected를 true로 주고 싶은데
이 setSelected의 값을 어떠한 방법으로 줘야하는지 모르겠습니다.
xml상에서 setSelected의 값을 true로 주는 방법은 없는것입니까?? 없다면 메인쪽에서라도 설정하는 방법을 알고싶습니다.
xml문서..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:layout_height="168dip"
android:focusable="true"
android:paddingLeft="8dip"
android:paddingRight="8dip"
style="@style/WidgetBackground" >
<TextView
android:id="@+id/word_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dip"
android:includeFontPadding="false"
android:singleLine="true"
android:ellipsize="end"
style="@style/Text.WordTitle"/>
<TextView "marquee" 가 적용되어야 할 부분.
android:id="@+id/word_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_below="@id/word_title"
style="@style/Text.WordType" />
<TextView
android:id="@+id/bullet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:maxLines="7"
android:layout_below="@id/word_type"
style="@style/Text.BulletPoint" />
</RelativeLayout>
2009.08.12 12:34:39
xml에서 selected를 처리하는 것은 없어보입니다. 메인쪽?이라는 것이 무엇을 말하는지 모르겠는데 그냥 코드에서 setSelected 호출해서 사용해서 안되는 이유가 있는것인지요.
2009.08.12 13:10:47
<TextView
android:id="@+id/word_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:setSelected="true"
android:layout_below="@id/word_title"
style="@style/Text.WordType" />
이렇게 추가를 하면 ERROR No resource identifier found for attribute 'setSelected' in package 'android' 라고 에러가 납니다.
메인이라고 적었놨는데... 그게 xml이 아닌 일반 자바 파일 코드상에서 해결하는 방법이라도 알고싶습니다.
android:id="@+id/word_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:setSelected="true"
android:layout_below="@id/word_title"
style="@style/Text.WordType" />
이렇게 추가를 하면 ERROR No resource identifier found for attribute 'setSelected' in package 'android' 라고 에러가 납니다.
메인이라고 적었놨는데... 그게 xml이 아닌 일반 자바 파일 코드상에서 해결하는 방법이라도 알고싶습니다.
2009.08.12 13:27:55
TextView musicString = (TextView) findViewById(R.id.xxx);
mMusicString.setSelected(true);
mMusicString.setSelected(true);
2009.08.12 13:50:42
답변 달아주셔서 감사합니다.
제가 하는 것은 위젯을 만드는 건데요.. AppWidgetProvider와 매 주기마다 업데이트를 위한 Service 를 상속받은 두개의 클래스가 있습니다.
이 두곳에서 앙자 님이 쓰신 것처럼 많은 시도를 이미 해봤었지만 먹혀들지를 않았습니다. findViewById를 찾을수가 없나봅니다. 그래서 혹시나 xml 상에서 할수있는 방법이 없을까 해서 질문 드렸습니다.
혹시 Activity 클래스 하나를 생성해서 실행시켜야 하는건가요?? 그렇다면 Activity 클래스 안에서 setSelected를 true값을 주면 되는 건지 알고싶습니다.
제가 하는 것은 위젯을 만드는 건데요.. AppWidgetProvider와 매 주기마다 업데이트를 위한 Service 를 상속받은 두개의 클래스가 있습니다.
이 두곳에서 앙자 님이 쓰신 것처럼 많은 시도를 이미 해봤었지만 먹혀들지를 않았습니다. findViewById를 찾을수가 없나봅니다. 그래서 혹시나 xml 상에서 할수있는 방법이 없을까 해서 질문 드렸습니다.
혹시 Activity 클래스 하나를 생성해서 실행시켜야 하는건가요?? 그렇다면 Activity 클래스 안에서 setSelected를 true값을 주면 되는 건지 알고싶습니다.