Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BaseFragment extends Fragment {
- protected SwipeRefreshLayout swipeContainer;
- protected ContentLoadingProgressBar progressBar;
- protected TextView emptyListMsg;
- protected RecyclerView recyclerView;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.list_layout_default, container, false);
- Log.d("check_meg", "BaseFragment");
- swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
- swipeContainer.setColorSchemeResources(android.R.color.holo_red_light);
- recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
- LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
- layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
- recyclerView.setLayoutManager(layoutManager);
- recyclerView.setHasFixedSize(true);
- recyclerView.setNestedScrollingEnabled(false);
- emptyListMsg = (TextView) view.findViewById(R.id.empty_list_msg);
- progressBar = (ContentLoadingProgressBar) view.findViewById(R.id.pb_wait);
- return view;
- }
- <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:id="@+id/swipe_container"
- android:layout_height="match_parent">
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <android.support.v4.widget.ContentLoadingProgressBar
- android:id="@+id/pb_wait"
- style="?android:attr/progressBarStyleLarge"
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_centerInParent="true"
- android:indeterminate="true"
- android:indeterminateDrawable="@drawable/progress"
- android:visibility="gone"/>
- <TextView
- android:id="@+id/empty_list_msg"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:textSize="@dimen/title_text_size"
- android:text="first text"
- />
- <android.support.v4.widget.NestedScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scrollbarFadeDuration="2"
- android:scrollbars="vertical">
- <android.support.v7.widget.RecyclerView
- android:id="@+id/recycler_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </android.support.v4.widget.NestedScrollView>
- </RelativeLayout>
- public class TalkFragment extends BaseFragment {
- public TalkFragment() {
- // Required empty public constructor
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- super.onCreateView(inflater, container, savedInstanceState);
- View view = inflater.inflate(R.layout.fragment_talk, container, false);
- ((Button) view.findViewById(R.id.button)).setText("updated button");
- Log.d("check_meg", "TalkFragment");
- emptyListMsg.setText("updated text");
- emptyListMsg.setVisibility(View.VISIBLE);
- Toast.makeText(getContext(), emptyListMsg.getText().toString(), Toast.LENGTH_SHORT).show();
- return view;
- }
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- tools:context=".fragment.TalkFragment">
- <include
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:id="@+id/initial_layout"
- layout="@layout/list_layout_default" />
Add Comment
Please, Sign In to add comment