-2

배경 이미지로 텍스트 뷰를 사용하고 두 개의 이미지가 추가되어 이제이 두 이미지가 나를위한 버튼으로 작동하게됩니다 (뒤로 & 주문 단추) - iPHONE 내가 다른 활동을 호출 할이 버튼을 사용하여, 난 내 XML을 텍스트 뷰를 배치하고 있기 때문에,다른 활동을 호출하기 위해 텍스트 뷰에서 단추로 이미지를 변경하는 방법

<TextView 
    android:id="@+id/actionbar" 
    android:layout_width="fill_parent" 
    android:layout_height="40dip" 
    android:background="@drawable/header" 
    android:drawableLeft="@drawable/back" 
    android:drawableRight="@drawable/final_order" 
    android:gravity="center_vertical|center_horizontal" 
    android:shadowColor="@android:color/black" 
    android:shadowDx="1" 
    android:shadowDy="1" 
    android:shadowRadius="1" 
    android:text="Pizza" 
    android:textColor="#FFFFFF" 
    android:textSize="25dp" 
    android:textStyle="bold" /> 

답변

1

대신 텍스트 뷰의하여 ImageButton을 사용하여이 목표를 달성하기 위해 몇 가지 간단한 코드를 작성하시기 바랍니다

또는

텍스트 뷰 자체는 onclickevent

등이있다

textview.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View arg0) { 
       // TODO Auto-generated method stub 
           // call your activities using intent from here 

      } 
     }); 
+0

감사합니다,하지만 난에이 개 이미지를 사용하고 형제 왼쪽과 오른쪽에 다른, 그것은 그래서 난 아이폰 OS처럼 텍스트와 버튼 헤더를 만들 수있는 방법 코드 – user1369219

+0

의 몇 줄 적어주세요 가능하다면 – user1369219

+0

이것을 구현하는 IOS 링크를 게시 할 수 있습니까 ?? 그래서 귀하의 질문을 명확하게 얻을 수 있습니다 Bcoz 내 XML 파일에 붙여 넣을 때 그것은 괜찮아 보이는 –

0

매우 쉽게, 이것은 내가 어떤 activity_main.xml에 전면에 포함 내 header.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:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" > 

<Button 
    android:id="@+id/button_up" 
    android:layout_width="48dp" 
    android:layout_height="48dp" 
    android:drawableTop="@drawable/undo" /> 

<TextView 
    android:id="@+id/path" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerVertical="true" 
    android:padding="4dp" 
    android:textSize="18sp" 
    android:singleLine="true" 
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:layout_toRightOf="@+id/button_up" 
    android:layout_toLeftOf="@+id/button_play" 
    android:text="@string/path" /> 

<Button 
    android:id="@+id/button_play" 
    android:layout_width="48dp" 
    android:layout_height="48dp" 
    android:layout_toLeftOf="@+id/button_settings" 
    android:drawableTop="@drawable/play" /> 

<Button 
    android:id="@+id/button_settings" 
    android:layout_width="48dp" 
    android:layout_height="48dp" 
    android:layout_alignParentRight="true" 
    android:drawableTop="@drawable/settings" /> 

</RelativeLayout> 

입니다 내 애플 리케이션에 대한 기본 XML. 포함 후 구분선이 있고 다음은 내 listview 오순절 된 항목입니다. 회신

<?xml version="1.0" encoding="utf-8"?> 
<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:padding="4dp" 
android:background="@color/gray_light" 
android:orientation="vertical" > 

<include layout="@layout/header" /> 

<View 
    android:id="@+id/separator_up" 
    android:layout_width="fill_parent" 
    android:layout_height="2dp" 
    android:layout_marginTop="2dp" 
    android:background="@color/blue_light" /> 

<include layout="@layout/list" /> 

</LinearLayout> 
관련 문제