写代码的四点:
1.明确需求。要做什么?
2.分析思路。要怎么做?(1,2,3……)
3.确定步骤。每一个思路要用到哪些语句、方法和对象。
4.代码实现。用具体的语言代码将思路实现出来。
学习新技术的四点:
1.该技术是什么?
2.该技术有什么特点?(使用需注意的方面)
3.该技术怎么使用?(写Demo)
4.该技术什么时候用?(在Project中的使用场景 )
----------------------早计划,早准备,早完成。-------------------------
代码如下:
package com.gzqol.fjsharedlibrary.customview;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ExpandableListView;
import android.widget.ListView;
/**
* 解决ScrollView嵌套ExpandableListView,ExpandableListView显示不全的问题
* 注意:ScrollView嵌套ExpandableListView时,ExpandableListView很长超出了屏幕的高度,那么ScrollView会自动滚动到底部,
* 但是我们需要默认在顶部,所以在初始化的时候就让ScrollView获得焦点,滚动条自然就显示到顶部了。
* scrollView.setFocusable(true);
* scrollView.setFocusableInTouchMode(true);
* scrollView.requestFocus();
*/
public class ExpandableListViewForScrollView extends ExpandableListView {
public ExpandableListViewForScrollView(Context context) {
super(context);
}
public ExpandableListViewForScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ExpandableListViewForScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
/**
* 重写onMeasure方法,重新计算高度,达到使ExpandableListView适应ScrollView的效果
*
* @param widthMeasureSpec 宽度测量规则
* @param heightMeasureSpec 高度测量规则
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//Int