Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaned code #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,29 @@
import android.support.v4.view.ViewPager;

public class TabListener<T extends Fragment> implements ActionBar.TabListener {
private Fragment mFragment;

private final Activity mActivity;
private final String mTag;
//private final Class<T> mClass;
private ViewPager mPager;

/** Constructor used each time a new tab is created.
* @param activity The host Activity, used to instantiate the fragment
* @param tag The identifier tag for the fragment
* @param clz The fragment's Class, used to instantiate the fragment
*/
public TabListener(Activity activity, String tag, ViewPager pager) {
mActivity = activity;
mTag = tag;
//mClass = clz;
mPager = pager;
this.mActivity = activity;
this.mTag = tag;
this.mPager = pager;
}

/* The following are each of the ActionBar.TabListener callbacks */

public void onTabSelected(Tab tab, FragmentTransaction ft) {
// Check if the fragment is already initialized
/*if (mFragment == null) {
// If not, instantiate and add it to the activity
mFragment = Fragment.instantiate(mActivity, mClass.getName());
ft.add(android.R.id.content, mFragment, mTag);
} else {
// If it exists, simply attach it in order to show it
ft.attach(mFragment);
}*/

mPager.setCurrentItem(Integer.parseInt(mTag));
}

public void onTabUnselected(Tab tab, FragmentTransaction ft) {
/*if (mFragment != null) {
// Detach the fragment, because another one is being attached
ft.detach(mFragment);
}*/
//do nothing
}

public void onTabReselected(Tab tab, FragmentTransaction ft) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public void onPageSelected(int arg0) {
new TabListener<android.app.Fragment>(this, 4 + "", mPager));
mActionBar.addTab(tab);

//mActionBar.getTabAt(index).select();
}
catch (Exception e) {
Log.e("ViewPager", e.toString());
Expand All @@ -117,7 +116,6 @@ public int getCount() {

@Override
public android.support.v4.app.Fragment getItem(int position) {
//mActionBar.getTabAt(position).select();
return ArrayListFragment.newInstance(position);
}

Expand All @@ -126,6 +124,7 @@ public void setActionBar( ActionBar bar ) {
}
}


public static class ArrayListFragment extends ListFragment {
int mNum;

Expand Down