Having a ListView and a TangoButton styles in a page.

Put your problem here if it does not fit any of the other categories.

Having a ListView and a TangoButton styles in a page.

Postby Nitinkcv » Sun Dec 23, 2007 4:43 pm

Hi all,

With reference to the MiniGMaps by lordhong which has the toolbar sort of layout in the bottom with the 4 imagebuttons;

Can i have a layout in which i have that toolbar at the top while the rest of the view has a ListActivity.

I have the following main.xml:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    >
  13.  
  14.  
  15.  
  16.         <view class="lordhong.apps.ToolBar$ToolBarView"
  17.  
  18.                 id="@+id/toolbar"
  19.  
  20.                 android:layout_width="fill_parent"
  21.  
  22.                 android:layout_height="wrap_content"/>
  23.  
  24. </LinearLayout>
  25.  
  26.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


But then i could not have my main activity which extends the ListActivity and then use setContentView(R.layout.main);

Since that would throw up ClassCastException.

So can i have some main.xml like this:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    >
  13.  
  14.  
  15.  
  16.         <view class="abc.apps.ToolBar$ToolBarView"
  17.  
  18.                 id="@+id/toolbar"
  19.  
  20.                 android:layout_width="fill_parent"
  21.  
  22.                 android:layout_height="wrap_content"/>
  23.  
  24.  
  25.  
  26.          <view class="abc.apps.MyListActivity"
  27.  
  28.                 id="@+id/listactivity"
  29.  
  30.                 android:layout_width="fill_parent"
  31.  
  32.                 android:layout_height="wrap_content"/>
  33.  
  34. </LinearLayout>
  35.  
  36.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4



Thanks,
Nitin
Nitinkcv
Developer
Developer
 
Posts: 29
Joined: Thu Nov 29, 2007 1:02 pm

Top

Postby plusminus » Sun Dec 23, 2007 7:47 pm

Hello Nitinkcv,

I think you are mixing up the words a bit. An Activity consists of different Views, these Views can once again consist of other Views but not of Activities :!:

So yes, you can of course reuse the toolbar by lordhong. The easiest would be to copy the ToolBar.java$ToolbarView (ToolbarView should be an inner Class of ToolBar) to your own project and adapt the icons/listeners or whatever needs to be changed to fit your purposes.

So your Activity would be a ListActivity with ToolBar followed by a ListView.
Take a look at this tutorial: :src: Creating Custom Views - The ToggleButton and this topic: :src: XML-ListView android.R.id.list ???.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

unable to inflate!!!

Postby Nitinkcv » Wed Dec 26, 2007 3:32 pm

Hi,

My main.xml file is:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:orientation="vertical"
  4.    android:layout_width="fill_parent"
  5.    android:layout_height="fill_parent"
  6.    >
  7.  
  8.         <view class="com.cognizant.GFM2.Toolbar$ToolBarView"
  9.                
  10.                 android:layout_width="fill_parent"
  11.                 android:layout_height="wrap_content"/>
  12.  
  13.         <ListView id="@android:id/list"
  14.    android:layout_width="fill_parent"
  15.    android:layout_height="wrap_content"
  16.    />
  17.  
  18. </LinearLayout>
  19.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


However im getting the exception
Binary XML file line #8: Error inflating class com.cognizant.GFM2.Toolbar$ToolBarView

In my onCreate method i have applied setContentView(R.layout.main);
In the mail.xml had also tried to give the layout as:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:orientation="vertical"
  4.    android:layout_width="fill_parent"
  5.    android:layout_height="fill_parent"
  6.    >
  7.  
  8.         <view class="com.cognizant.GFM2.Toolbar$ToolBarView"
  9.                 id="@+id/toolbar"
  10.                 android:layout_width="fill_parent"
  11.                 android:layout_height="wrap_content"/>
  12.  
  13.         <com.cognizant.GFM2.GeneralizedFileManager2
  14.          android:layout_width="fill_parent"
  15.          android:layout_height="wrap_content"
  16.    />
  17.  
  18. </LinearLayout>
  19.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


I had seen a couple of posts reg this error message. But was not able find out the prob.

Thanx,
Nitin
Nitinkcv
Developer
Developer
 
Posts: 29
Joined: Thu Nov 29, 2007 1:02 pm

Postby plusminus » Wed Dec 26, 2007 11:29 pm

Hello

did you write the following constructor in your custom View-Class:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.    public ToggleButton(Context context, AttributeSet attrs, Map params)
  2.  
  3.     {
  4.  
  5.         super(context, attrs, params);
  6.  
  7.     }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

It is needed to Inflate from XML.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests