添加了自定义适配单选按钮
This commit is contained in:
@@ -0,0 +1,83 @@
|
|||||||
|
package com.zhy.autolayout.widget;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
|
import com.zhy.autolayout.AutoLayoutInfo;
|
||||||
|
import com.zhy.autolayout.utils.AutoLayoutHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by hupei on 2016/2/29 9:59.
|
||||||
|
*/
|
||||||
|
public class AutoRadioGroup extends RadioGroup
|
||||||
|
{
|
||||||
|
private AutoLayoutHelper mHelper = new AutoLayoutHelper(this);
|
||||||
|
|
||||||
|
public AutoRadioGroup(Context context)
|
||||||
|
{
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AutoRadioGroup(Context context, AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
||||||
|
{
|
||||||
|
if (!isInEditMode())
|
||||||
|
mHelper.adjustChildren();
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int l, int t, int r, int b)
|
||||||
|
{
|
||||||
|
super.onLayout(changed, l, t, r, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LayoutParams generateLayoutParams(AttributeSet attrs)
|
||||||
|
{
|
||||||
|
return new LayoutParams(getContext(), attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LayoutParams extends RadioGroup.LayoutParams
|
||||||
|
implements AutoLayoutHelper.AutoLayoutParams
|
||||||
|
{
|
||||||
|
private AutoLayoutInfo mAutoLayoutInfo;
|
||||||
|
|
||||||
|
public LayoutParams(Context c, AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(c, attrs);
|
||||||
|
mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AutoLayoutInfo getAutoLayoutInfo()
|
||||||
|
{
|
||||||
|
return mAutoLayoutInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LayoutParams(int width, int height)
|
||||||
|
{
|
||||||
|
super(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(ViewGroup.LayoutParams source)
|
||||||
|
{
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(MarginLayoutParams source)
|
||||||
|
{
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -368,6 +368,16 @@ public class BaseFragment extends Fragment {
|
|||||||
listView.setVisibility(View.VISIBLE);
|
listView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setEmptyView(ListView listView, String text) {
|
||||||
|
TextView emptyView = new TextView(getContext());
|
||||||
|
emptyView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
emptyView.setText(text);
|
||||||
|
emptyView.setGravity(Gravity.CENTER);
|
||||||
|
emptyView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||||
|
emptyView.setVisibility(View.GONE);
|
||||||
|
((ViewGroup) listView.getParent()).addView(emptyView);
|
||||||
|
listView.setEmptyView(emptyView);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user