I m still new to android and working on my first application. so far so good. among others the app will contain a ViewPager to switch between different xml layouts through swiping. this works nice.
however I would like to use the ViewPagerIndicator to indicate the position of the displayed template.
so i tried to include the code based on different tutorials/ instructions to my project but the templates/ ViewPager wont show anymore, the app breaks at that point. Thanks for any hints in advance ;)
here is the code + logCat
And in the xml you have:
<com.viewpagerindicator.TabPageIndicator
android:id="#+id/indicator"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
But you are using UnderlinePageIndicator in your code, so it should be:
<com.viewpagerindicator.UnderlinePageIndicator
android:id="#+id/indicator"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
If it's not a typo, your missing a paranthesis in this line:
UnderlinePageIndicator indicator = UnderlinePageIndicator)findViewById(R.id.indicator);
should be
UnderlinePageIndicator indicator = (UnderlinePageIndicator)findViewById(R.id.indicator);
Related
I am using ViewPager with PagerTabStrip:
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.PagerTabStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"/>
</android.support.v4.view.ViewPager>
And I would like to accomplish my tabs to look like this as Google recommends:
I have two tabs and I would like for each of them to be fixed and take 50% of the screen. I was looking through the options in XML and programmatically and can't find anything useful.
How can I accomplish that? Thank you.
I'm not sure about android.support.v4.view.PagerTabStrip. But you can use alternative library for getting this effect, i use it in my one project and it works well. After you add the lib to your project, set pstsShouldExpand to true
You should use android.support.design.widget.TabLayout instead of PagerTabStrip.
what I need here is actually difficult to express in words. I am using viewpager to transact between fragments in my android app. But I also want to show which fragment user is seeing currently by showing small dots below.
Please see the image to get a clear view of what I am trying to say. So, is there any library or something to achieve this.
Please let me know. Thanks in advance. :-)
1)First of all download ViewPagerIndicator Library Project from this Location :: http://viewpagerindicator.com/
2). Add that Project as Library in your Application.
3). Add this code in your XML where you have define ViewPages as well.
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:layout_centerHorizontal="true"
android:padding="10dip"
app:fillColor="#FFFFFF"
app:pageColor="#000000"
app:radius="5dp"
app:strokeColor="#C0C0C0"
app:strokeWidth="1dp"
/>
4). Create Reference in Activity side eg: private CirclePageIndicator circlePageIndicator;
5). Create Object eg:circlePageIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
6). Pass ViewPager Object into this Method
circlePageIndicator.setViewPager(viewPagerObj);
It is call PageIndicatior. This is library that you can use for implementation
https://github.com/JakeWharton/Android-ViewPagerIndicator
So i use SlidingMenu library with a FragmentActivity in my app.
There is a GoogleMap in the layout and a menu on the left side with some content.
When i pull the menu to see it, there is a big black rectangle there, covering my sliding menu content. After i click it once, it is disapearing.
Can anybody has something to say about this?
I had the same issue on android 2.3.7 but not in 3.x or later versions. After rotating the view the menu renders fine after.
I found a solution using a custom TransparentSupportMapFragment from: Android MapView With Sliding Menu Obscures Menu
Fragment Black screen issue
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
<!-- hack to fix ugly black artefact with maps v2 -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent" />
</FrameLayout>
This is a known problem.
You may want to have a look at these issues:
http://code.google.com/p/gmaps-api-issues/issues/detail?id=4639
http://code.google.com/p/gmaps-api-issues/issues/detail?id=4659
Maybe you can find a workaround in comments there.
I know this question is too old but since I come here by chance and see there is no accpeted answer I will answer this.Hope it help someone someday.
My solution is add a light layout (about 1dp) with transparent background above the "Shopradar" layout of yours. This worked for me,hope it works for you too ;)
I have to use SlidingDrawer in my app. I know this class is deprecated but it very useful to do what i want so i have decided to use it.
I've used this link
Android: can height of SlidingDrawer be set with wrap_content?
in order to use wrap_content when the SlidinDrawer is open. It works perfect on android 4.2.2 with AOSP rom but with android 4.0.4 on SGSII (Samsung rom), i have some display problem when i open or close the SlidingDrawer. If there is no action, the widget appears correctly.
Have you any idea why there is this problem ?
Edit : Here is a screenshot. The problem disappeared when i took a screenshot, so to see the problem i took a photo with another device.
Alternate to SlidingDrawer is "Custom Sliding Drawer".
Sephiroth has created one of it. It has option to sliding up and down. It has handler which is used like actual handle to open and close Sliding Drawer.
I will suggest you to implement this custom one. This will solve your problem.
You just need to define following in your layout
<view class="it.sephiroth.demo.slider.widget.MultiDirectionSlidingDrawer"
xmlns:my="http://schemas.android.com/apk/res/it.sephiroth.demo.slider"
android:id="#+id/drawer"
my:direction="topToBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
my:handle="#+id/handle"
my:content="#+id/content">
<include android:id="#id/content"
layout="#layout/pen_content" />
<imageview android:id="#id/handle"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:src="#drawable/sliding_drawer_handle_bottom" />
</view>
Thats it. Your sliding drawer is ready to work.
I have 2-3 Activities in my app that all share data in a memory pool. I want to be able to easily switch between these activities while keeping them all simultaneously running. In addition, I am developing for Android 4.0. I would like to use TabActivity, but it has been deprecated and replaced with ActionBar, which I have tried but I don't think it's what I'm looking for. I want large tabs, similar to the classic "Artist/Playlist/All" tabs found in the stock Android Music Application, or like the Tab Bar seen at the bottom of the screenshot below. Does anyone know of a library to create these tabs or a way to make ActionBar more customizable? Or is using TabActivity a perfectly good solution, even on ICS devices?
ActionBar is what you're looking for, actually.
You should convert your Activites to Fragments. Assuming they're not too complex, this shouldn't be hard at all. There are tons of examples out there. You need one Activity, preferably a FragmentActivity, to hold all of them.
This should help:
http://arvid-g.de/12/android-4-actionbar-with-tabs-example
There are several subquestions to this, I'll try to address them all:
-In order to use the top tabs, you want to use an ActionBar.
-If you were to do it in the style of the music app, where you swipe sideways between views and the label of the current one is always front and center... For that, the class you'd want to use is called ViewPager
You can see all of these methods by creating a new Activity in eclipse, and going through the wizard. Under "Navigation Type" you can select "Tabs", "Tabs + Swipe", "Swipe Views + Title Strip". Create any one of those Activities to see how it looks, and then look at the code to see how it's implemented & how to customize it.
-Navigation along the bottom is discouraged- See the Android Design Guide, spec the section "Don't use Bottom Tab Bars"
You have probably found an answer by now, but I thought I'll share another way you could create something like that tab bar using images and xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="#+id/main">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/tabackground"
android:layout_alignParentBottom="true"
android:id="#+id/llBottom">
<ImageButton
android:src="#drawable/icon2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
/>
<ImageButton
android:src="#drawable/icon3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
/>
<ImageButton
android:src="#drawable/icon4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
/>
<ImageButton
android:src="#drawable/icon5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00000000"
/>
</LinearLayout>
<ImageView
android:layout_height="24dp"
android:layout_width="fill_parent"
android:layout_alignTop="#+id/llBottom"
android:background="#10ffffff"/>
<ImageView
android:layout_height="1dp"
android:layout_width="fill_parent"
android:layout_alignTop="#+id/llBottom"
android:background="#30ffffff"/>
</RelativeLayout>
Is not perfect but with some creativity and changing some values it can look very good.
Hope it helps in some way.