android-layout

Why we use ViewTreeObserver#addOnGlobalLayoutListener()

こ雲淡風輕ζ 提交于 2020-08-24 07:29:32
问题 Why do we use ViewTreeObserver , please can anyone explain it? In below code creditsView is TextView object. By this whole code I understand that "this is to hide some text based on condition", but only thing is why we are using ViewTreeObserver ? mainLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int heightDiff = mainLayout.getRootView().getHeight() - mainLayout.getHeight(); if (heightDiff > 100)

Disable swipe in fragmentPagerAdapter? - android

南楼画角 提交于 2020-08-24 06:38:34
问题 Hey guys i have a fragmentPagerAdapter with 3 fragments in it. How would i disable the swiping between the 3 fragments so the user only uses the tabview to go between fragments? Cheers! private class ViewPagerAdapter extends FragmentPagerAdapter { ArrayList<Fragment> fragments = new ArrayList<>(); ArrayList<String> tabTitles = new ArrayList<>(); public ViewPagerAdapter(android.support.v4.app.FragmentManager fragmentManager) { super(fragmentManager); } @Override public Fragment getItem(int

recycler View Item it is not showing Ripple effect/touch highlight, i applied Listener by using gesture Detractor

走远了吗. 提交于 2020-08-24 03:54:32
问题 recyclerView.addOnItemTouchListener(new MyListClickListener(getContext(), new MyListClickListener.ClickListener() { @Override public void onClick(View v, int position) { TextView textView = (TextView) v.findViewById(R.id.title); Fragment fragment = ((MyPagerAdapter) viewPager.getAdapter()).getFragment(1); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.detach(fragment); fragment.onDestroy(); ft.attach(fragment); ft.commit(); comm.sendData(String.valueOf(textView.getText()

access parent fragment by child fragment

佐手、 提交于 2020-08-21 07:59:28
问题 this is my child fragment and how to access my parent fragment from this fragment please help me to fix it public class Profilefragmant extends Fragment { public Profilefragment(){} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.profile_layout, container, false); TextView VE = (TextView) rootView.findViewById(R.id.profile_view_enquiry); VE.setOnClickListener(new View.OnClickListener(){