두 개의 XML 파일이 있습니다. 그 중 하나에는 ListView와 listView를 채우는 사람이 있습니다. 나는 항목을 표시 할 수 있지만 것은 스크롤 할 수 없습니다. 예를 들어 표시 할 항목 목록이 있지만 스크롤을 자동으로 활성화하지는 않습니다. 스크롤 할 수 있도록 코드의 어느 부분을 향상시켜야합니다. ListView를 사용하면 기본적으로 스크롤 할 수 있습니다. 이걸로 나를 도와주세요. 미리 감사드립니다.ListView를 스크롤 가능하게하기
public class ActivityViewCategory extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_products);
// Hashmap for ListView
productsList = new ArrayList<HashMap<String, String>>();
// Get listview
ListView lv = getListView();
.
.
.
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
ArrayList<HashMap<String, String>> com.example.restotrial.ActivityViewCategory.productsList * */
ListAdapter adapter = new SimpleAdapter(
ActivityViewCategory.this, productsList,
R.layout.list_item, new String[] { TAG_PID,
TAG_NAME},
new int[] { R.id.pid, R.id.name });
// updating listview
setListAdapter(adapter);
}
});
}
}
activity_view_products.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- Main ListView
Always give id value as list(@android:id/list)
-->
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="456dp" >
</ListView>
</LinearLayout>
list_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Product id (pid) - will be HIDDEN - used to pass to other activity -->
<TextView
android:id="@+id/pid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<!-- Name Label -->
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="6dip"
android:paddingLeft="6dip"
android:textSize="17dip"
android:textStyle="bold" />
</LinearLayout>
이 답변을 확인하십시오 : http://stackoverflow.com/questions/4310738/making-android-listview-layout-scrollable – verybadalloc
질문을 수정하여 시도한 다른 답변을 포함시킬 수 있습니까? 그것은 내가 당신의 문제에 대한 해결책을 찾는 나의 범위를 줄이는데 도움이 될 것입니다. – verybadalloc