1

I'm attempting to port an iphone app to the android. Inside of the app there is a static bar with five buttons that acts like a menu bar (ie clicking one button will bring up a corresponding page) This bar does not go away and it should light up depending on what button is pressed. I don't know how to get started on this and was wondering if anyone could give me some help. Here are the buttons. Thank youButtons

Sean
  • 1,123
  • 4
  • 24
  • 44

1 Answers1

1

In my opinion, this is not a good idea to copy an iPhone app. User interfaces (and therefore user behaviours) are totally different and iPhone and Android devices. Ask yourself "is it the right way to do it on Android?" If you are not sure, just don't do it. But do like other developers on Android do.

You can follow this tutorial to start http://developer.android.com/resources/tutorials/views/hello-tabwidget.html then (only when you understand it) try something like this for each of your tabs:

// Initialize a TabSpec for each tab and add it to the TabHost

spec = mTabHost.newTabSpec("Name of tab");
v = View.inflate(this, R.layout.tabbar_tabview, null);
((ImageView)v.findViewById(R.id.tabbar_tabview_img)).setBackgroundResource(R.drawable.ic_tab_expenses);
((TextView)v.findViewById(R.id.tabbar_tabview_text)).setText(R.string.general_tab_expenses);
spec.setIndicator(v);
spec.setContent(intent);
mTabHost.addTab(spec);

This is the content of my "tabbar_tabview.xml":

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:padding="0dp"
    android:layout_height="fill_parent" android:layout_width="fill_parent"
        android:background="@drawable/tabview_background">

    <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/tabbar_tabview_img"
        android:layout_gravity="center" android:layout_marginTop="5dp"></ImageView>

    <TextView  android:id="@+id/tabbar_tabview_text" android:layout_width="wrap_content"
        android:gravity="center" android:layout_height="wrap_content" android:textSize="13dp" android:layout_marginBottom="5dp"
        android:layout_gravity="center" android:textColor="@drawable/tabview_text_color"></TextView>

</LinearLayout> 

And this is the content of my tabview_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true">
        <shape>
             ### I defined a shape here ###
        </shape>
    </item>

    <item>
        <shape>
             ### I defined a shape here ###
        </shape>
    </item>
</selector>
Gilbou
  • 5,244
  • 6
  • 24
  • 27
  • @Gibou - Excellent response (+1 for it): "In my opinion, this is not a good idea to copy an iPhone app. User interfaces (and therefore user behaviours) are totally different and iPhone and Android devices" – Abhijit Jan 04 '12 at 16:58