Scrollable TabHost

Quickly share your Android Code Snippets here...

Postby Boni2k » Mon Jan 18, 2010 10:38 am

No it doesn't happen without ProgressDialog :-)
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Top

Postby Boni2k » Tue Jan 26, 2010 12:00 am

Hello, me again.
I plan to release my software to the market in the next coming days. Do you have an idea how to get rid of this progressdialog behavior? :-)

Greetings!
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Postby Boni2k » Tue Jan 26, 2010 10:06 pm

By the way, this bug is more severe than I thought: If ProgressDialog is called, it will call the onCheckChanged of ScrollableTabActivity twice which can cause several problems.

EDIT: Found a way to resolve the onCheckChanged. I now use onClickListener instead of onCheckChangedListener:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. tabButton.setId(i);
  2.  
  3. tabButton.setGravity(Gravity.LEFT);
  4.  
  5. tabButton.setOnClickListener(new TabBarButton.OnClickListener() {
  6.  
  7.       public void onClick(View v) {
  8.  
  9.             try
  10.  
  11.             {
  12.  
  13.                   if (delegate!=null) delegate.onTabChanged(tabButton.getId());
  14.  
  15.             }
  16.  
  17.             catch (Exception e){}
  18.  
  19.             startGroupActivity( titleList.get(tabButton.getId()).toString(), (Intent) intentList.get(tabButton.getId()));      
  20.  
  21.       }
  22.  
  23. });
  24.  
  25. bottomRadioGroup.addView(tabButton, i, buttonLayoutParams);
  26.  
  27.                
  28.  
  29. if (tabButton.getId() == intentList.size()-1) {  //if last tab was added, activate first one
  30.  
  31.       startGroupActivity( titleList.get(tabButton.getId()).toString(), (Intent) intentList.get(0));
  32.  
  33.       bottomRadioGroup.check(0);
  34.  
  35. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


This works good for me.
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Re: Scrollable TabHost

Postby sebseb3 » Mon Jul 11, 2011 11:21 am

Hi guys !

I'm kind of a noob in the android development, and I found this project that looks really awesome !
I tried to use it but I get an error when I click on the button that should send me to my screen with tabs. I changed my old TabActivity for a ScrollableTabActivity, here is my code :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class Creation extends ScrollableTabActivity {
  2.        
  3.         public void onCreate(Bundle savedInstanceState) {
  4.  
  5.                 super.onCreate(savedInstanceState);
  6.                 setDelegate(new SliderBarActivityDelegateImpl());
  7.                 setDefaultShade(RadioStateDrawable.SHADE_GRAY, RadioStateDrawable.SHADE_GREEN);
  8.                        
  9.                 this.addTab("Client", R.drawable.star, new Intent(this, Client.class));
  10.                 this.addTab("Construction", R.drawable.star, new Intent(this, Construction.class));
  11.                
  12.                 commit();
  13.                
  14.         }
  15.  
  16.         }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


and here is my button to access it :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        
  2.                         Intent intent = new Intent(this, Creation.class);
  3.                                 startActivity(intent);
  4.                         } catch (Exception e) {
  5.                                 Log.e("Error in creation", e.getMessage());
  6.                         }
  7.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


and finally my error :


07-11 10:14:23.941: ERROR/AndroidRuntime(364): FATAL EXCEPTION: main
07-11 10:14:23.941: ERROR/AndroidRuntime(364): java.lang.NoClassDefFoundError: com.project.seven.Creation
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at com.project.seven.Menu1.onClick(Menu1.java:33)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at android.view.View.performClick(View.java:2408)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at android.view.View$PerformClick.run(View.java:8816)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at android.os.Handler.handleCallback(Handler.java:587)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at android.os.Handler.dispatchMessage(Handler.java:92)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at android.os.Looper.loop(Looper.java:123)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at java.lang.reflect.Method.invoke(Method.java:521)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-11 10:14:23.941: ERROR/AndroidRuntime(364): at dalvik.system.NativeStart.main(Native Method)


I'm really sorry but I really don't understand why it won't open it as it was working before, with my TabActivity. I only put two tabs but it should be around 15 at the end so I really need this to work. I'm working on a Galaxy Tab on android 2.2, this project is for a company and they WANT tabs.
WOuld you have an idea ? I think this class Creation stay an activity so I don't know if I should change something in the manifest...

Every advice is appreciated, thank you very much !!

Seb
sebseb3
Freshman
Freshman
 
Posts: 2
Joined: Sun Jul 10, 2011 10:12 pm

Re: Scrollable TabHost

Postby Boni2k » Mon Jul 11, 2011 11:35 am

Did you add your activity to your Android Manifest file?
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Re: Scrollable TabHost

Postby sebseb3 » Mon Jul 11, 2011 11:37 am

Thanks for your response !

My manifest contains all my activities. Here are Creation, Construction and Client :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        
  2.         <activity android:name=".Creation"
  3.                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
  4.                           android:screenOrientation="landscape"
  5.                 />
  6.                
  7.         <activity android:name=".Client"
  8.                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
  9.                           android:screenOrientation="landscape"
  10.                 />
  11.        
  12.         <activity android:name=".Construction"
  13.                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
  14.                           android:screenOrientation="landscape"
  15.                 />
  16.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


When I start the application, it tells me taht it can't find the class Creation.class of my project?? I don't understand why, cause when I used the TabActivity, it was working fine....
sebseb3
Freshman
Freshman
 
Posts: 2
Joined: Sun Jul 10, 2011 10:12 pm

Top

Re: Scrollable TabHost

Postby Boni2k » Thu Jul 14, 2011 10:54 pm

Sorry, you got me on a cold spot. No idea.

I eventually used my own implementation, which is very similiar to that one here. It consists of a FrameLayout(tabcontent) with height=0dp, a HorizontalScrollView with several RadioButtons and a TabWidget - all packed in a LinearLayout. It works better for me that way.
Boni2k
Experienced Developer
Experienced Developer
 
Posts: 88
Joined: Sun Dec 20, 2009 9:46 pm

Re: Scrollable TabHost

Postby wiliamsmith4444 » Sat Jul 16, 2011 5:28 pm

It looks a bit odd in the video. When you click on a button, it turns green, but momentarily turns gray again. It does not happen in the demo. Is that what you want? Or is it another bug.
wiliamsmith4444
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Jul 16, 2011 5:00 pm

Top
Previous

Return to Code Snippets for Android

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests