안녕하세요 여러분, 목록보기를 아래로 스크롤하면 해당 목록이 LayoutInflater와 함께 사용됩니다.안드로이드 ListView 항목이 스크롤 위로 겹쳐진 경우
실제로 한 번만 첫 번째 행이 문제가 발생하는 것보다 화면 밖으로 나옵니다. 여기
리스트 뷰 여기
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:showAsAction="always"
android:background="#0066FF" >
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="false"
android:cacheColorHint="#00000000"
android:dividerHeight="1dp"
android:scrollbars="none">
</ListView>
</LinearLayout>
레이아웃 내가 목록보기에 전달하고있다이있는 자바 코드
public class VehicleActivity extends Activity
{
static ListView listView;
public int context_menu_index;
public void onCreate(Bundle savedInstanceState)
{
//Some Code
listView = (ListView) findViewById(R.id.list_view);
listView.setAdapter(new EfficientAdapter(this));
}
private class EfficientAdapter extends BaseAdapter
{
private LayoutInflater mInflater;
private TextView text1, text2, text3;
private View listItem;
private ImageView img_option;
//Some Code
public View getView(final int position, View convertView, ViewGroup parent)
{
if (convertView == null)
{
mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
listItem = mInflater.inflate(R.layout.three_col_row, null);
text1 = (TextView) listItem.findViewById(R.id.imei);
text2 = (TextView) listItem.findViewById(R.id.status);
text3 = (TextView) listItem.findViewById(R.id.location);
img_option = (ImageView) listItem.findViewById(R.id.img_arrow);
img_option.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
VehicleActivity.this.registerForContextMenu(listView); VehicleActivity.this.openContextMenu(listView);
context_menu_index = position;
}
})
img_option.setFocusable(true);
img_option.setClickable(true);
img_option.setTag(getItem(position));
//Setting The Font Style
text1.setTypeface(null, Typeface.BOLD);
text2.setTypeface(null, Typeface.ITALIC);
//Passing The Actual Values To TextViews
text1.setText("ID: " +VehicleList.IMEI[position]);
text2.setText("Status: " +VehicleList.Status[position]);
text3.setText("Location: " +VehicleList.Location[position]);
listItem.setBackgroundColor(position % 2 == 0 ? Color.parseColor("#eaeaea") : Color.parseColor("#d3e3f3"));
}
return listItem;
}
} }
다음되어 활동 레이아웃입니다
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_main"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:padding="4dp">
<LinearLayout
android:id="@+id/child_lay1"
android:layout_height="wrap_content"
android:layout_width="320dp"
android:orientation="vertical"
android:gravity="start">
<TextView
android:id="@+id/imei"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_marginLeft="10dp"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#000000"/>
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_marginLeft="10dp"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#000000"/>
<TextView
android:id="@+id/location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:layout_marginLeft="10dp"
android:textSize="15sp"
android:textColor="#000000"/>
</LinearLayout> <!-- Child Vertical Linear Layout -->
<LinearLayout
android:id="@+id/child_lay2"
android:layout_height="30dp"
android:layout_width="30dp"
android:orientation="vertical"
android:gravity="end">
<ImageView
android:id="@+id/img_arrow"
android:src="@drawable/arrow"
android:layout_width="30dp"
android:layout_height="30dp"/>
</LinearLayout>
</LinearLayout>
당신의 자바 소스 코드를 업로드하세요 ...... –
@Rajatsharma 코드를 확인하십시오 –