선형 뷰 내부에 ListView가 있습니다. listview에는 사용자 정의 cursoradapter가 있습니다. ListView가 스크롤되지 않는 것을 제외하면 모든 것이 잘 작동합니다.ListView가 스크롤되지 않습니다. 어떻게 수정해야합니까?
어떤 제안이라도 환영합니다! 감사.
마우리 치오
다음은 여기에 자바 코드의 관련 부분이다 MainActivity<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/buttonAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Aggiungi" />
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
의 XML입니다.
public class MainActivity extends Activity {
private DatabaseHelper db=null;
private Cursor tabellaCursor=null;
private ListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int[] to = new int[] {R.id.name_entry};
db = new DatabaseHelper(this);
tabellaCursor=db.getWritableDatabase().rawQuery("SELECT _id, colonna1, colo nna2, colonna3 FROM tabella ORDER BY _id", null);
ListAdapter adapter=new MyAdapter(this, R.layout.list_example_entry, tabe llaCursor, new String[]{"colonna1"},to);
ListView lt = (ListView)findViewById(R.id.list);
lt.setAdapter(adapter);
Button addbtn=(Button)findViewById(R.id.buttonAdd);
addbtn.setOnClickListener(new OnClickListener()
{public void onClick(View v){add(); }
});
}
맞아요, 항목을 추가하면 스크롤됩니다. –
관련이 없지만 올바른 방향으로 나를 잡았다. 나는 물건이 많다고 생각했다. 목록에 있지만 2 개가 있었고 예, 스크롤하지 않았습니다 .. 10 개의 항목을 추가 한 후. 나는 그것이 올바르게 스크롤되는 것을 보았다. – reidisaki