ScrollViewでネストされたListViewには1行の問題のみが表示されます

1145 ワード

今回の解決は、ScrollViewにネストされたListViewが1行しか表示されない問題です.
1つの解決策は、ScrollViewでカスタムListViewを使用することです.
package activity.MyWeather;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View.MeasureSpec;
import android.widget.ListView;

public class MyListView extends ListView{

	public MyListView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public MyListView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		// TODO Auto-generated constructor stub
	}

	public MyListView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
		int expandSpec = MeasureSpec.makeMeasureSpec(
				Integer.MAX_VALUE>>2, MeasureSpec.AT_MOST);
		super.onMeasure(widthMeasureSpec, expandSpec);
	}

}

ここで問題が発生する可能性があります.開くときに最初に表示される位置が最初ではありません.
1つの解決策はlistViewのフォーカスをFalseに設定することです
forecast_listview.setFocusable(false);