이미지 및 단추가 포함 된 사용자 지정 Listview를 사용하고 있습니다.여러 LinearLayout 내 ImageView ID 가져 오기
내 listview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
/>
</LinearLayout>
여기 3은 LinearLayouts을 취급하고 있습니다.
내 button_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"
android:id="@+id/parent"
>
<LinearLayout
android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/child1"
<ImageView
android:id="@+id/image"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/image"
/>
<TextView
android:id="@+id/listarray"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:id="@+id/child2">
<ImageButton
android:id="@+id/one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/one"
/>
<ImageButton
android:id="@+id/two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/two"
/>
<ImageButton
android:id="@+id/three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
어댑터 코드 내 목록을 포함
tweetArray.
ArrayAdapter<String> arrayAdapter =new ArrayAdapter<String>(this,R.layout.button_view, R.id.listarray, tweetArray);
ListView listView = (ListView) findViewById(android.R.id.list);
listView.setAdapter(arrayAdapter);
문제 : 내 문제는 내가 어떻게 ImageView
의 ID를 얻을 수 있다는 것입니다. 시도
: 나는
ImageView user_picture = (ImageView) findViewById(R.id.image);
Picasso.with(getApplicationContext()).load("http://www.w3schools.com/css/trolltunga.jpg).into(user_picture);
으로 간단한 방법으로 얻을 시도하지만이 오류을 보여주고있다 : 대상이 널 (null)이 아니어야합니다.
아이디어가 있습니까? 그 코드가`Adapter`에있는 경우
에 대한 링크를 확인하십시오 어댑터 을 사용자 정의, 당신은에'findViewById를을()'를 호출하는 데 필요한'View' 당신 ' 목록 항목을 다시 팽창시킵니다. –
@MikeM하는 방법. – Atula
'Adapter'에 대한 코드를 게시해야합니다. –