由于部分界面比如一个Fragment 他的布局文件 几乎就是几行代码 并且好几个list列表的Fragmentxml几乎都一样
xml 个数激增 此时部分小布局放在代码中去 我感觉会更好
也有利于 防止 反编译
package yangdc.common.fragment.base;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
public class BaseListFragment extends BaseFragment{
public PullToRefreshListView pullToRefreshListView;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
FrameLayout frameLayout = new FrameLayout(getActivity());
pullToRefreshListView = new PullToRefreshListView(getActivity(),Mode.BOTH);
pullToRefreshListView.setLayoutParams(
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
)
);
frameLayout.addView(pullToRefreshListView);
return frameLayout;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}