머리글을 추가 한 목록보기가 있습니다. 그러나 머리글 주위에 목록보기 배경이 나타나지 않게하십시오.목록보기에서 머리글 배경을 제거하십시오.
- :<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.example.tuto.customs.CustomHoverView
android:id="@+id/chv_activity_list_with_header"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/lv_activity_list_with_header"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/carreblanc"
android:cacheColorHint="#00000000"
>
</ListView>
</com.example.tuto.customs.CustomHoverView>
</LinearLayout>
헤더 :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Header" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/ic_launcher" />
</LinearLayout>
BaseAdapter 클래스가 두 개의 서로 다른 견해처럼
목록보기를 (내가있는 ScrollView 내부의 목록보기를 넣어하지 않음)
private class MyAdapter extends BaseAdapter{
private LayoutInflater inflater;
private List<String> strings;
public MyAdapter(Context context, List<String> strings) {
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.strings = strings;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return strings.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return strings.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View v = convertView;
ViewHolder h;
if(v == null){
v = inflater.inflate(R.layout.adapter_strings, null);
h = new ViewHolder();
h.tv = (TextView) v.findViewById(R.id.tv_adapter_strings);
v.setTag(h);
}else{
h = (ViewHolder) v.getTag();
}
if(position == 0){
// here it changes the first item, but not the header
v.setBackgroundColor(Color.RED);
}
h.tv.setText(""+getItem(position));
return v;
}
private class ViewHolder{
TextView tv;
}
}
어댑터 :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_adapter_strings"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
는
당신의 어댑터에서 이것을 처리하십시오, –
더 설명 할 수 있습니까? – Tsunaze
위치가 0 인 경우 getView 메서드에 대한 배경을 변경하고 위치가 0이 아닌 경우 다른 배경을 설정하십시오. –