標籤:android
由於部分介面比如一個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); }}
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
純Java方式 開發Android UI介面