こんにちは、マージ アダプタを使用してリスト ビューを作成しています。しかし、ヘッダーに問題があります。リストとは無関係にスクロールしているように見えますが、多くの場合、ページの上部にスナップするだけです。ヘッダーが所定の位置に留まるようにするにはどうすればよいですか?または、これを引き起こす可能性のある人はいませんか?
ここに私のコードがあります
arrayAdapter = new ArrayAdapter<String>(this, R.layout.single_item, newsList);
arrayAdapter2 = new ArrayAdapter<String>(this, R.layout.single_item, newsList2);
arrayAdapter3 = new ArrayAdapter<String>(this, R.layout.single_item, newsList3);
RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams labelLayoutParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
layout.setLayoutParams(labelLayoutParams);
ImageView mImage = new ImageView(this);
mImage.setBackgroundResource(R.drawable.titlerect);
layout.addView(mImage,labelLayoutParams);
TextView latestFixtures;
latestFixtures = new TextView(this);
latestFixtures.setText("Latest League Fixture");
layout.addView(mImage,labelLayoutParams);
ListView list = getListView();
list.setTextFilterEnabled(true);
setListAdapter (arrayAdapter);
adapter = new MergeAdapter();
adapter.addView(layout);
adapter.addAdapter(arrayAdapter);
adapter.addView(layout);
adapter.addAdapter(arrayAdapter2);
adapter.addView(layout);
adapter.addAdapter(arrayAdapter3);
setListAdapter(adapter);
}
コード
05-15 13:35:14.489: E/ListView(1045): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
05-15 13:35:14.489: E/ListView(1045): at android.widget.ListView.setupChild(ListView.java:1834)
05-15 13:35:14.489: E/ListView(1045): at android.widget.ListView.makeAndAddView(ListView.java:1803)
05-15 13:35:14.489: E/ListView(1045): at android.widget.ListView.fillDown(ListView.java:670)
05-15 13:35:14.489: E/ListView(1045): at android.widget.ListView.fillFromTop(ListView.java:727)
05-15 13:35:14.489: E/ListView(1045): at android.widget.ListView.layoutChildren(ListView.java:1646)
05-15 13:35:14.489: E/ListView(1045): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
05-15 13:35:14.489: E/ListView(1045): at android.view.View.layout(View.java:7277)
05-15 13:35:14.489: E/ListView(1045): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
05-15 13:35:14.489: E/ListView(1045): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
05-15 13:35:14.489: E/ListView(1045): at android.widget.TableLayout.onLayout(TableLayout.java:440)
05-15 13:35:14.489: E/ListView(1045): at android.view.View.layout(View.java:7277)
05-15 13:35:14.489: E/ListView(1045): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
05-15 13:35:14.489: E/ListView(1045): at android.view.View.layout(View.java:7277)
05-15 13:35:14.489: E/ListView(1045): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
05-15 13:35:14.489: E/ListView(1045): at android.view.View.layout(View.java:7277)
05-15 13:35:14.489: E/ListView(1045): at android.view.ViewRoot.performTraversals(ViewRoot.java:1203)
05-15 13:35:14.489: E/ListView(1045): at android.view.ViewRoot.handleMessage(ViewRoot.java:1957)
05-15 13:35:14.489: E/ListView(1045): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 13:35:14.489: E/ListView(1045): at android.os.Looper.loop(Looper.java:143)
05-15 13:35:14.489: E/ListView(1045): at android.app.ActivityThread.main(ActivityThread.java:4263)
05-15 13:35:14.489: E/ListView(1045): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 13:35:14.489: E/ListView(1045): at java.lang.reflect.Method.invoke(Method.java:507)
05-15 13:35:14.489: E/ListView(1045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-15 13:35:14.489: E/ListView(1045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-15 13:35:14.489: E/ListView(1045): at dalvik.system.NativeStart.main(Native Method)