Open parin9097 opened 10 years ago
Thank you very much for your patronage, you have to put your code, I can help you.
package main.java.me.xiaopan.android.pagerslidingtabstrip.sample;
import java.util.ArrayList; import java.util.List; import java.util.Random;
import main.java.me.xiaopan.android.pagerslidingtabstrip.PagerSlidingTabStrip; import main.java.me.xiaopan.android.pagerslidingtabstrip.R; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.v4.view.ViewPager; import android.view.Menu; import android.view.MenuItem; import android.view.View;
/**
å¸¦æ»‘åŠ¨æ ‡é¢˜çš„ViewPager */ public class SlidingTabStripActivity extends Activity { private static final int[] colors = new int[]{Colors.SKYBLUE, Colors.CHOCOLATE, Colors.CYAN, Colors.FUCHSIA, Colors.GOLD, Colors.BLUE, Colors.GREEN, Colors.RED, Colors.YELLOW, Colors.GRAY}; private main.java.me.xiaopan.android.pagerslidingtabstrip.PagerSlidingTabStrip pagerSlidingTabStrip1; private main.java.me.xiaopan.android.pagerslidingtabstrip.PagerSlidingTabStrip pagerSlidingTabStrip2; private main.java.me.xiaopan.android.pagerslidingtabstrip.PagerSlidingTabStrip pagerSlidingTabStrip3; private main.java.me.xiaopan.android.pagerslidingtabstrip.PagerSlidingTabStrip pagerSlidingTabStrip4; private ViewPager viewPager1; private ViewPager viewPager2; private ViewPager viewPager3; private ViewPager viewPager4;
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sliding_tab_strip); pagerSlidingTabStrip1 = (PagerSlidingTabStrip) findViewById(R.id.slidingTabStrip_1); pagerSlidingTabStrip2 = (PagerSlidingTabStrip) findViewById(R.id.slidingTabStrip_2); pagerSlidingTabStrip3 = (PagerSlidingTabStrip) findViewById(R.id.slidingTabStrip_3); pagerSlidingTabStrip4 = (PagerSlidingTabStrip) findViewById(R.id.slidingTabStrip_4); viewPager1 = (ViewPager) findViewById(R.id.viewPager_1); viewPager2 = (ViewPager) findViewById(R.id.viewPager_2); viewPager3 = (ViewPager) findViewById(R.id.viewPager_3); viewPager4 = (ViewPager) findViewById(R.id.viewPager_4);
init(0, pagerSlidingTabStrip1, viewPager1);
init(1, pagerSlidingTabStrip2, viewPager2);
init(2, pagerSlidingTabStrip3, viewPager3);
init(3, pagerSlidingTabStrip4, viewPager4);
}
private void init(int index, PagerSlidingTabStrip pagerSlidingTabStrip, ViewPager viewPager){
int length = pagerSlidingTabStrip.getTabCount();
List
private View getContentView(int color){ View view = new View(getBaseContext()); view.setBackgroundColor(color); return view; }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint({ "NewApi", "AlwaysShowAction" }) @Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem menuItem = menu.add("Github"); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } return super.onCreateOptionsMenu(menu); }
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://github.com/xiaopansky/Android-PagerSlidingTabStrip")); startActivity(intent); return super.onOptionsItemSelected(item); } }
And xml file is exactly same as per you documentation of the library in github.
How much chinese you speak
I can't speak actually i translate the language in translator.
You put your APP source code to me I see
If possible, please send to my mailbox sky@xiaopan.me
The code above is my app source code and all other are class files like Colors.java and ViewPagerAdapter file and the package with this main.java.me.xiaopan.android.pagerslidingtabstrip and in this package PagerSlidingTabStrip.java file.
Hello , i solved the previous issue but now i stuck in other problem. how can i get the click of particular tab and as per the click i can navigate to particular activity?
You can register to listen for events by setOnClickTabListener method
Thank you.it works fine.now how can i work with it like tabs . like opening a new activity like we can click on tabs
Sorry, I don't understand your needs, and therefore can not understand you do so
"https://play.google.com/store/apps/details?id=com.myntra.android". This is the link of myntra application. i want to achieve exactly same as per this app. thing which can be done on click of tabs.i want to implement that thing. please help me and install this app. Thank you for your cooperation.
Are you worried about not by clicking on the TAB switch to ViewPaeer?
Yes exactly i want to achieve this thing.
On click of these tabs i want to open their layouts in viewpager.
Thanks.
You need to call pagerSlidingTabStrip.setViewPager(viewPager) method to bind the ViewPager, PagerSlidingTabStrip will monitor the TAB Click events and ViewPager switching
yes i know that but how can i set my layout in viewpager and can flip the layouts in viewpager
You can't use ViewPager?
i used viewpager for it
You don't know how to use ViewPager?
I know and i can used it in many projects but cannot open actvities like this so that it irritates me.
You want to put Activity in ViewPager?
Yes i want to put activity in viewpager
Activity cannot be placed in the ViewPager. But Fragment and View can be placed in the ViewPager
how to put the fragment in viewpager?
Which country do you come from?
I am from india . and you are from?
china
can you help me please?
You need to learn how to use the Fragment, recommended Android official tutorial http://developer.android.com/training/basics/fragments/index.html
Thank you very much
You're welcome
Hey thanks for your great cooperation. i achieve the thing i want. thank you,.
I have a ViewPager, and FragmentPagerAdpater and 3 Fragments to implement an tab swipe view. Is the ViewPager supposed to "remember" the 3 views after first time rendering?
My problem is that after some time, the layouts of the 3 views are "forgotten". That means I need to update them again and user will see the ugly part before updating.
Is there a view holder pattern for viewpager as well? What technique can i use to remain those already rendered views or preventing them being destroyed?
call ViewPager.setOffscreenPageLimit(3)
Hello. Functionality works absolutely fine but i cannot see the tab indicator. what is the reason behind it? please help me. Thanks in advance.