@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.sticky_checkBox: stickyList.setAreHeadersSticky(isChecked); break; case R.id.fade_checkBox: fadeHeader = isChecked; break; case R.id.draw_behind_checkBox: stickyList.setDrawingListUnderStickyHeader(isChecked); break; case R.id.fast_scroll_checkBox: stickyList.setFastScrollEnabled(isChecked); stickyList.setFastScrollAlwaysVisible(isChecked); break; } }
@Override public View onCreateView( final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View view = inflater.inflate(R.layout._artist_tab_profile_fragment, container, false); setHasOptionsMenu(true); mAdapter = new ShowProfileAdapter(getActivity(), header, body); stickyList = (StickyListHeadersListView) view.findViewById(R.id.listProfileShowMan); stickyList.setOnItemClickListener(this); stickyList.setOnHeaderClickListener(this); stickyList.setOnStickyHeaderChangedListener(this); stickyList.setOnStickyHeaderOffsetChangedListener(this); View headerView = getActivity().getLayoutInflater().inflate(R.layout.list_header, null); ImageView imageView = (ImageView) headerView.findViewById(R.id.imageViewShowMan); imageView.setImageResource(R.mipmap.ic_launcher); stickyList.addHeaderView(headerView); // stickyList.addFooterView(getLayoutInflater().inflate(R.layout.list_footer, null)); // stickyList.setEmptyView(findViewById(R.id.empty)); stickyList.setDrawingListUnderStickyHeader(true); stickyList.setAreHeadersSticky(true); stickyList.setAdapter(mAdapter); stickyList.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == 11) { Intent intent = new Intent(getActivity(), ShowFeedbacks.class); startActivity(intent); getActivity().overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left); } } }); return view; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout); refreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { new Handler() .postDelayed( new Runnable() { @Override public void run() { refreshLayout.setRefreshing(false); } }, 1000); } }); mAdapter = new TestBaseAdapter(this); stickyList = (StickyListHeadersListView) findViewById(R.id.list); stickyList.setOnItemClickListener(this); stickyList.setOnHeaderClickListener(this); stickyList.setOnStickyHeaderChangedListener(this); stickyList.setOnStickyHeaderOffsetChangedListener(this); stickyList.addHeaderView(getLayoutInflater().inflate(R.layout.list_header, null)); stickyList.addFooterView(getLayoutInflater().inflate(R.layout.list_footer, null)); stickyList.setEmptyView(findViewById(R.id.empty)); stickyList.setDrawingListUnderStickyHeader(true); stickyList.setAreHeadersSticky(true); stickyList.setAdapter(mAdapter); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */); // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); restoreButton = (Button) findViewById(R.id.restore_button); restoreButton.setOnClickListener(buttonListener); openExpandableListButton = (Button) findViewById(R.id.open_expandable_list_button); openExpandableListButton.setOnClickListener(buttonListener); updateButton = (Button) findViewById(R.id.update_button); updateButton.setOnClickListener(buttonListener); clearButton = (Button) findViewById(R.id.clear_button); clearButton.setOnClickListener(buttonListener); stickyCheckBox = (CheckBox) findViewById(R.id.sticky_checkBox); stickyCheckBox.setOnCheckedChangeListener(checkBoxListener); fadeCheckBox = (CheckBox) findViewById(R.id.fade_checkBox); fadeCheckBox.setOnCheckedChangeListener(checkBoxListener); drawBehindCheckBox = (CheckBox) findViewById(R.id.draw_behind_checkBox); drawBehindCheckBox.setOnCheckedChangeListener(checkBoxListener); fastScrollCheckBox = (CheckBox) findViewById(R.id.fast_scroll_checkBox); fastScrollCheckBox.setOnCheckedChangeListener(checkBoxListener); stickyList.setStickyHeaderTopOffset(-20); }