For an application I am designing we have to deal with some "special" needs of our users. One of these is to create a navigation sidebar that has to appear in almost all the activities.
This navigation bar has to contain always the same three buttons that links to three activities: HOME, INFO, CONFIGURATION.
Each of these three activities can also load others activities that can (or cannot) contain this navigation bar.
Each of these buttons has to reset the current activity-stack status bringing to the top the corresponding activity selected by the user.
The navigation bar has to be customisable (made visible/invisible) and I would like also to deactivate some of the buttons.
EDIT: It has to be similar to a Drawer, but the buttons have to be highly customisable (in size and appearance) and it has to be always on (no sliding functions).
What is the best way to achieve that without manually including those buttons in each of my layouts?
You can create this layout manually but only once - in your ActivityBase class. Other activities can extend this base class.
EDIT:
As I said, I'm improving my answer.
So my idea is to create an Activity with menu. And if other Activity needs to have the same menu it can extend this ActivityBase and add it's own layout.
Let's look on a simple example.
ActivityBase layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<RelativeLayout
android:id="#+id/menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:color/black" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button1"
android:layout_centerHorizontal="true"
android:text="Button" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/button2"
android:layout_alignBottom="#+id/button2"
android:layout_alignParentRight="true"
android:text="Button" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/menu" >
</RelativeLayout>
</RelativeLayout>
As you can see I created a simple layout that contains menu bar and a container for layout from Activities that will be extending AcivityBase.
Now ActivityBase:
public class ActivityBase extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_base);
}
}
It's a simple Activity, but if you want, you can also place here menu events handling if they are the same for all Activities that will be extending this.
And now let's see at SecondActivity's layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
It's a normal layout, nothing special. I put some controls in there just for purpose of this example.
And SecondActivity class:
public class SecondActivity extends MainActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = getLayoutInflater();
inflater.inflate(R.layout.second_activity, (ViewGroup) findViewById(R.id.container));
}
}
It extends ActivityBase and what is important - it does not call setContentView. Instead we are creating LayoutInflater and we are inflating second_activity layout in the container that we created in activity_base layout.
Related
i have seen tutorials about fragments where a main activity is created with buttons for changing fragment after fragment. my question is, can i change fragments using the button of the called layout instead of the main activity's button/s. that is my current dilemma. before, my app runs using intent to change activities. but i came across a problem where i need to use fragment to solve it.
here is my "main" fragment code:
public class FragmentMain extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment_main);
Log.d("Batelec", "fragment main started");
}
public void selectFrag(View view) {
Fragment fr;
fr = new FragmentMain2();
FragmentManager fm = getFragmentManager();
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(R.id.fragment1, fr);
fragmentTransaction.commit();
}
}
here's my layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.mypower_build101.FragmentMain" >
<fragment
android:id="#+id/fragment1"
android:name="com.example.mypower_build101.FragmentMain2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
and here's my main activity xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<Button
android:id="#+id/btnAddDevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="#string/txtAddDevice"
android:onClick="addClick" />
<Button
android:id="#+id/btnShowDevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btnAddDevice"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:text="#string/txtShowDevice"
android:onClick="showClick" />
<Button
android:id="#+id/btnMainRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btnShowDevice"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:text="#string/txtRegister"
android:onClick="registerClick" />
<Button
android:id="#+id/btnShowDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btnMainRegister"
android:layout_centerHorizontal="true"
android:layout_marginTop="29dp"
android:text="#string/txtShowDialog" />
<TextView
android:id="#+id/txtStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btnShowDialog"
android:layout_centerHorizontal="true"
android:layout_margin="#dimen/listViewPadding"
android:layout_marginTop="20dp"
android:text="#string/txtNull"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Switch
android:id="#+id/switchGCM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:checked="false"
android:text="#string/txtConnect2GCM"
android:textOff="#string/txtNo"
android:textOn="#string/txtYes" />
<TextView
android:id="#+id/txtBroadCastMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/lblStatus"
android:layout_alignStart="#+id/lblStatus"
android:layout_below="#+id/lblStatus"
android:layout_marginTop="17dp"
android:gravity="center"
android:text="#string/txtNull"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
if i really need to create buttons outside my already functioning activity, can you give some tips on how to properly code them i've seen that using static is not the best way to do it. also give me some tips on how to place the new button in the fragment because my main activity has 4 buttons which already used for changing activities.
all help is very much appreciated
Well, what you want to do is best to use fragments that programmatically additions on the activity.
I'll leave a small project where I have about an activity, and using two buttons, one fragment screen replacement by another.
You can find the complete code in the link that sends Gitub and you can download if you want is free for you to use and analyze as you wish.
Fragmetn replaces another Fragment. Github Project
And I leave the screenshot so you can see how it works.
I hope that my help has been very useful.
so you mean, i still need to have a separate button for changing activities and i can't anymore use my previous buttons. i just thought, can i use my previous main activity then call an activity which contain a fragment. when i click a button the main activity, the button calls the "fragmented" activity and change the fragment it calls
like this sorry the say i am not allowed to put image here yet
I developed an app, that uses Fragments as part of a Fragment.
public class LoginFragment extends Fragment
EditTextWithCameraButtonFrag userNameFrag;
EditTextWithCameraButtonFrag passwordFrag;
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
userNameFrag = (EditTextWithCameraButtonFrag)getChildFragmentManager()
.findFragmentById(R.id.fragment_username);
passwordFrag = (EditTextWithCameraButtonFrag) getChildFragmentManager()
.findFragmentById(R.id.fragment_password);
EditTextWithCameraButtonFrag is a subtype of Fragment.
This code works like a charm, running on android 5.1.1.
However, running it on Android 4.4.2 returns in userNameFrage and passwordFrag being null. So it seems, that the returned Child FragmentManager does not find the fields.
Is there any thing to consider when using getChildFragmentManager()with 4.4.3?
Thanks in advance!
EDIT:
This is the main fragment's XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/huge"
android:orientation="vertical" >
<TextView
android:id="#+id/login_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:gravity="center"
android:textColor="#color/white"
android:textSize="40dp" />
<fragment
android:id="#+id/fragment_username"
android:name="com.example.app.fragments.EditTextWithCameraButtonFrag"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<fragment
android:id="#+id/fragment_password"
android:name="com.example.app.fragments.EditTextWithCameraButtonFrag"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/huge"
android:layout_marginStart="#dimen/huge"
android:layout_marginTop="#dimen/normal"
android:padding="#dimen/half"
android:text="Login" />
</LinearLayout>
And this the sub fragment's:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/editText_with_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/text_input_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.75"
android:background="#drawable/edit_text_login_top"
android:inputType="text"
android:padding="#dimen/normal" />
<Button
android:id="#+id/scan_text_view"
android:layout_width="wrap_content"
android:background="#android:color/transparent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/text_input_field"
android:layout_alignTop="#+id/text_input_field"
android:layout_alignBottom="#+id/text_input_field"
/>
</RelativeLayout>
I just solved it- kinda.
After a LOT of reading it seems like it's possible to declare nested fragments via XML, but is not best practice.
So I decided to include FrameLayouts in the XML, and add the nested
Fragments via FragmentTransaction.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/huge"
android:orientation="vertical" >
<TextView
android:id="#+id/login_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:gravity="center"
android:textColor="#color/white"
android:textSize="40dp" />
<FrameLayout
android:id="#+id/fragment_username"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#+id/fragment_password"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/huge"
android:layout_marginStart="#dimen/huge"
android:layout_marginTop="#dimen/normal"
android:padding="#dimen/half"
android:text="Login" />
</LinearLayout>
</RelativeLayout>
And in the main fragment's onCreate:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// create userNameFrag
EditTextWithCameraButtonFrag userfragment = new EditTextWithCameraButtonFrag();
getChildFragmentManager().beginTransaction().replace(R.id.fragment_username, userfragment).commit();
// create passwordFrag
EditTextWithCameraButtonFrag passfragment = new EditTextWithCameraButtonFrag();
getChildFragmentManager().beginTransaction().replace(R.id.fragment_password, passfragment).commit();
}
This seems to work pretty good and- another plus- I also got rid of the the duplicate id bug.
From the code it is not clear where are these two fragments added:
1) Added in activity (in xml or in onCreate method)
Then this fragments are associated to fragemnt manager which belongs to Activity. You should use getActivity().getFragmentManager().find...
2) Fragemnts added in fragemnt xml layout
then they will be available after calling fragments onViewCreated method
Use getChildFragmentManager() for fragments which are defined in xml layout of this fragment or for fragments which are added by this getChildFragmentManager() fragment manager.
I'm trying to create a custom view component which looks like this:
a component will work as a menu - it has 4 imageviews inside which react to onClick event.
I made a separate .xml with them and a class for it. Than i set the parent node class from .xml "class = 'myclass'".
In my .xml an imageview has a onClick declared, but when i try to handle it using myclass - application crashes. What is wrong? Or I suppose the main question is: what is a right way to set event handlers for a custom view?Handlers which are in this views class definition. Should I write in .xml of a view something like
Addition: how do I, then, can fire events from this custom view for activity which will hold it to handle?
Here is my menu .xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
class="com.example.mtgesturestest.MTMenuViewController"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/main_layout" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/imageChannels"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/channels"
android:layout_marginBottom="10dp" />
<ImageView
android:id="#+id/imageMessages"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/messages"
android:layout_marginBottom="10dp" />
<ImageView
android:id="#+id/imageTimeline"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/timeline"
android:onClick="yell"
android:layout_marginBottom="10dp" />
</RelativeLayout>
<ImageView
android:id="#+id/imageMenu"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/menu"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-15dp"
android:onClick="maximizeMenu"/>
</RelativeLayout>
Application says it cant find onClick handler (maximizeMenu), but its searching it in the activity where I add this view instead of com.mtgesturestest.MTMenuViewController class. I want this menu to be independent. It should handle click, play some animation and then fire event for parent activity. So you can say that this onClick here is for inner use of my custom view.
Why not try to add the onClick listener from inside the MTMenuViewController class like
ImageView menu = (ImageView)this.findViewById(R.id.imageMenu);
menu.setOnClickListener(PUT THE LISTENER HERE);
I'm trying to create a music player that will be visible in all my activities. To do this, I'm going to use a Fragment as some of you advised me earlier.
Since I have no experience with Fragments whatsoever, I decided to implement a fragment in a "filler" activity first.
I created a simple fragment containing only a button and some text, and try to inflate that in my filler activity.
However, after inflating this fragment does not show up. A message does get printed to LogCat telling me that the fragment has been inflating.
I'm pretty sure I'm missing something, but since I have no experience with this and I couldn't find a tutorial that quite explained how to do this, I don't know what it is that I'm missing.
Music player Fragment
public class AppMusicPlayer extends Fragment{
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
System.out.println("fragment added");
return inflater.inflate(R.layout.musicplayer_main, container, false);
}
}
Music Player layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is the fragment you're looking for" />
</LinearLayout>
Filler Activity
public class Filler extends FragmentActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.filler);
Button b = (Button) findViewById(R.id.terug);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
}
}
Filler layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- Title bar -->
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/title_bar" >
<TextView
android:id="#+id/fillertitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Work In Progress"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" >
</TextView>
<Button
android:id="#+id/terug"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:background="#drawable/button_back"
android:text="Back"
android:textColor="#FFFFFFFF"
android:textStyle="bold" >
</Button>
</RelativeLayout>
<!-- End of title bar -->
<TextView
android:id="#+id/wip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This section of the app has not been made yet. Work in progress." >
</TextView>
<fragment
android:id="#+id/musicPlayerFragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:name="com.mobowski.app.player.AppMusicPlayer" />
</LinearLayout>
Obviously I'm doing something wrong, but what?
Note: I'm using Android 2.3 with the Compatibility library.
Any help is appreciated
The problem has been fixed with the help of Yashwanth Kumar and blessenm. One gave an XML solution, the other a programmatic solution. Now I'm just wondering which solution is the most desirable one. Are there any concessions to be made with either of the solutions, or does it all boil down to the programmer's preferred solution?
I haven't tried adding fragments directly to xml. But what I normally do is add a framelayout or linearlayout to the filler layout.
Suppose its id is 'fragment_holder'. I use the following code in the fragment activity right after setContentView. Try this
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.fragment_holder,new AppMusicPlayer(),"musicplayer");
ft.commit();
you should mention layout_height as 0dip, not the width in vertical linear layout.
change that it should work.
<fragment
android:id="#+id/musicPlayerFragment"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:name="com.mobowski.app.player.AppMusicPlayer" />
I am developing an app with tabs. On one of the tabs,
I have two EditText fields and a couple of buttons. I want to add an ExpandableListView
to the tab, below the rest of the elements.
My problem is that the current class extends Activity. All the example I've found extend ExpandableListActivity, but I can't extend both for the same class.
How can I add this list to the tab? I've added an ExpandableListView element in the XML file, but whenever I run it, it doesn't show up. I understand that I need to bind the view to some data, but how do I go about doing this?
Thank you.
Here is my class code:
public class DirectionsTab extends Activity
{
private Button clear_btn;
private Button go_btn;
private EditText origin_txt;
private EditText dest_txt;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.directions_tab);
// initialize views and onClick event handler
origin_txt = (EditText)findViewById(R.id.origin_txt);
dest_txt = (EditText)findViewById(R.id.dest_txt);
clear_btn = (Button)findViewById(R.id.clear_btn);
// clear all text fields and return focus to dest_txt
clear_btn.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v)
{
origin_txt.setText("");
dest_txt.setText("");
origin_txt.requestFocus();
}
});
} // end public void onCreate(Bundle savedInstanceState)
} // end public class DirectionsTab extends Activity
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">
<TextView
android:id="#+id/origin_lbl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Origin"/>
<EditText
android:id="#+id/origin_txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background"
android:layout_below="#id/origin_lbl"/>
<TextView
android:id="#+id/dest_lbl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/origin_txt"
android:text="Destination" />
<EditText
android:id="#+id/dest_txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background"
android:layout_below="#id/dest_lbl" />
<ExpandableListView
android:id="#+id/listView"
android:layout_below="#+id/dest_txt"
android:layout_height="wrap_content"
android:layout_width="wrap_content" /><!--android:id="#android:id/list"-->
<Button style="?android:attr/buttonStyleSmall"
android:id="#+id/clear_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/dest_txt"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:text="Clear" />
<Button style="?android:attr/buttonStyleSmall"
android:id="#+id/go_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/clear_btn"
android:layout_alignTop="#id/clear_btn"
android:text="Go!" />
</RelativeLayout>
I got this!, If anyone is having problems with this, make sure you follow these steps:
Copy and paste ExpandableList3 example (located in ApiDemos project from Samples folder in your Android SDK). This is just a good example of how to set up a list.
Make your class inherit from ExpandableListActivity
Create the following in your XML layout file:
<ExpandableListView
android:id="#android:id/list"
android:layout_below="#+id/go_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
It is VERY important that the ID property matches what you see above, otherwise, nothing will work. This little detail wasted plenty of hours for me and was discovered seating neatly as a small detail in the android docs.