맞춤 위젯을 만들고 싶습니다.이렇게 맞춤형 위젯을 만드는 방법은 무엇입니까?
은 다음과 같습니다
을 그래서, Button
를 확장해야 내가 그것을 클릭하고 싶은 때문에?
어떻게 이미지를 이미지에 넣을 수 있습니까? 나는 이미 방법 onDraw()
에 대해서 읽었지 만, 나는 어떻게 넣을 지 모른다. image
.
맞춤 위젯을 만들고 싶습니다.이렇게 맞춤형 위젯을 만드는 방법은 무엇입니까?
은 다음과 같습니다
을 그래서, Button
를 확장해야 내가 그것을 클릭하고 싶은 때문에?
어떻게 이미지를 이미지에 넣을 수 있습니까? 나는 이미 방법 onDraw()
에 대해서 읽었지 만, 나는 어떻게 넣을 지 모른다. image
.
단지 컴필드 객체로 만들 수 있습니다. 한면에 드로어 블이있는 TextView입니다.
텍스트 뷰를 클릭 할 수 있으므로 클릭 핸들러를 실행할 수 있습니다. 이 같은
뭔가 :
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/ic_launcher"
android:drawablePadding="8dp"
android:text="Title\nA little description for this object"
android:textSize="16sp"
android:onClick="click_handler"
/>
그럼 그냥 코드에 추가
public void click_handler(View v)
{
// Do something in your click event
}
오, 네, 고맙습니다.이 물체에 대해, 나는 당신의 도움을 사용할 것입니다. 정확히 검색 한 것입니다. –
디자인을 평평하게하고 성능을 향상시키기 위해 ** 모범 사례 **로 간주됩니다. –
넣어 다. 해당 레이아웃에 클릭 리스너를 추가하십시오. 나중에 예를 들어 ListView에서 레이아웃을 사용할 수 있습니다.
당신이
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
......
android:layout_alignParentLeft="true" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
android:layout_toRightOf="@+id/imageView"
android:layout_alignTop="@+id/imageView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
android:layout_below="@+id/textView1"
android:layout_alignLeft="@+id/textView1" />
</RelativeLayout>
을 사용 그리고 그것을
을 처리하는 클래스를 쓸 수 있습니다
http://stackoverflow.com/questions/2252323을 확인하십시오. 2/inflate-into-this/22680619? noredirect = 1 # comment34621831_22680619 – Gaskoin
원하는 레이아웃으로 LinearLayout을 만들어 단추를 작성하는 데 사용해야합니다. – randomizer