2012-03-15 8 views
1

나는 정상적인 방식으로 구현 한 목록보기가 있습니다. 편집보기와 단추를 목록보기의 맨 위에 표시하고 목록보기의 모든 항목에는 표시하지 않습니다. 누군가가편집 상자와 버튼을 헤더로 사용하는 Android보기

+1

에서 통해 UR 현재 작업에 대한 SRC를 제공하고 우리는 더 나은 도움을 줄 수. – Deva

+0

액티비티/레이아웃/매니페스트 항목이 추가되었는지 확인하십시오. – Deva

답변

1

내가 해석 할 수있는 것에 따라 당신은 다음과 같은 것을 시도 할 수있다. 이 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#FF000000" > 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/linearLayout1" 
     android:orientation="horizontal" 
     > 
    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/et1" 
     /> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/bt1" 
     android:text="ClickMe" 
     /> 
    </LinearLayout> 
    <ListView 
     android:id="@+id/list" 
     android:layout_below="@id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:divider="#000000" /> 


</RelativeLayout> 

필요에 따라 일부 매개 변수를 사용자 정의해야 할 수도 있습니다. 희망이 도움이됩니다.

편집 1 : 해당 Java 클래스

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 

public class AtoZActivity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     ListView lv=(ListView) findViewById(R.id.list); 
     String[] values = new String[] { "Android", "iPhone", "WindowsMobile", 
       "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", 
       "Linux", "OS/2" }; 

      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
       android.R.layout.simple_list_item_1, android.R.id.text1, values); 

      // Assign adapter to ListView 
      lv.setAdapter(adapter); 
    } 
} 

그리고 매니페스트

<application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 
     <activity 
      android:label="@string/app_name" 
      android:name=".AtoZActivity" > 
      <intent-filter > 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 
+0

도움 주셔서 감사합니다 – user1092042

1
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/listado_ly_search" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:orientation="horizontal" > 

     <EditText 
      android:id="@+id/listado_tb_filtro" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.45" android:layout_gravity="center_vertical"> 

     </EditText> 

     <Button 
      android:id="@+id/listado_iv_search" 
      android:layout_width="48dp" 
      android:layout_height="48dp" android:background="@android:drawable/ic_menu_search"/> 


    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/LinearLayout01" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.5" 
     android:minHeight="200sp" 
     android:orientation="horizontal" > 


      <ListView 
       android:id="@+id/android:list" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_weight="1" 
       android:choiceMode="singleChoice" 
       android:drawSelectorOnTop="false" 
       android:minHeight="200sp" > 
      </ListView> 
    </LinearLayout> 
1

이와 노력이 목적을 위해 샘플 코드로 날을 제공 할 수있다 ..

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <EditText 
      android:id="@+id/edtxt" 
      android:layout_width="100dp" 
      android:layout_height="50dp" 
      android:inputType="none" /> 

     <Button 
      android:id="@+id/btn" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="2dp" 
      android:layout_marginRight="3dp" 
      android:layout_marginTop="2dp" 
      android:text="button" 
      android:textSize="15sp" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <ListView 
      android:id="@+id/list" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" > 
     </ListView> 
    </LinearLayout> 

</LinearLayout> 

자바 파일이

public class example extends Activity { 
private ListView listView; 
static String[] names; 
@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     listView = (ListView) findViewById(R.id.phlist); 
Button btn = (Button) findViewById(R.id.btn); 
EditText ed = (EditText)findViewById(R.id.edtxt); 
names = new String[] { "name1", "name2", "name3", "name4" }; 
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
       android.R.layout.simple_list_item_1, android.R.id.text1, values); 

      lv.setAdapter(adapter); 

btn.setOnClickListener(new OnClickListener() { 

      public void onClick(View v) { 
//write Ur Code for Button Clik 

} 
}); 

} 
} 

모양을이 link.it 월 참조 유용한 .. enter link description here

+0

edittext와 버튼을 헤더로 사용하고 목록보기를 채우기 위해 java 코드를 게시 해주세요. – user1092042

관련 문제