Skip to content
This repository has been archived by the owner on Jan 13, 2018. It is now read-only.

ListActivity no layout #39

Open
jmawebtech opened this issue Apr 30, 2013 · 2 comments
Open

ListActivity no layout #39

jmawebtech opened this issue Apr 30, 2013 · 2 comments

Comments

@jmawebtech
Copy link

Hi, how do I add the action bar to an activity where I have no layout file? If I have a class inheriting from list activity how do I use your solution?

@Cheesebaron
Copy link
Owner

Just like you would do with any other Android View, you can instantiate it something like:

var ab = new LegacyBar(this);
ab.LayoutParameters = new LayoutParameters(ViewGroup.LayoutParams.FillContent, ViewGroup.LayoutParams.WrapContent);
AddView(ab);

I haven't tested the code above and I suspect there might be some typos and additionally you will need to set some dimensions of the items inside the LegacyBar as well. We are looking into injecting the LegacyBar into views instead of having to manually declare it every time.

I will try to give you an better code snipping later today.

@jamesmontemagno
Copy link
Collaborator

I do not recommend this though...
You should inherit from LegacyBarListActivity and your layout would be:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ab="http://schemas.android.com/apk/res/legacybar.sample"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
   <legacybar.library.bar.LegacyBar
        android:id="@+id/actionbar"
        style="@style/actionbar"
        ab:title="Cool beans!"/>
    <ListView
        android:id="@+android:id/list"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
</LinearLayout>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants