[mono-android] Custom AccordionView

Atsushi Eno atsushieno at veritas-vos-liberabit.com
Thu Oct 4 16:46:30 UTC 2012


Hello,

Since you want to depend on resources in the Java library, you have to 
use "LibraryProjectZip" or "LibraryProjectProperties" instead of adding 
your jar library as "InputJar" (as it doesn't contain resources at all).

The easiest way (for me to explain) is 1) build your java project in 
Eclipse/ADT and 2) add your "project.properties" file (in your Eclipse 
project) to MfA binding library project as LibraryProjectProperties.

Or once you built your java library, create a zip file that contains 
"bin" and "res" directories from your project (important: first you have 
to *build* it) and add the zip to your MfA binding library project as 
LibraryProjectZip.

Then build the binding library.

Atsushi Eno

javitxin wrote:
> Hi, I am implementing an accordionView but until now..with not all success I
> wanted..
>
> First.. I used some java classes where the accordionView is developed..
>
> I assumed thay are ok.. with no bugs or errors.. This is the source:
>
> https://github.com/hamsterready/android-accordion-view
>
> As it is Java code.. I compile it using eclipse and get the jar file..
>
> My fisrt doubt is what to complile.. just java classes or java classes,
> resources or what..
>
> So.. I compiled java classes and some values resources (attrs.xml and
> colors.xml)
>
> Why Have I included these value resources? Because I think from
> AccordionView.java and ToggleImageLabeledButton.java these atributes are
> called by the Constructor.
>
>
> Supposing everything is ok.. I get my accordionView.jar...
>
> Then.. I create a jarsBinding project to get my dll and use it in my android
> app...
>
> Ok. At this point.. I assumed I have to include all necessary resources from
> the gihub project... I mean layouts and drawable...
>
> Then I create this layout to use my accordion but two things:
>
> One: my layout object(package.objectView) is blue underlined saying that the
> main layout has an invalid secondary element... but it compiles..
>
> When executing it crashes with this exception...
>
> "Binary XML file line #1: Error inflating class"
>
>
> I have read some post about this...and in most of them it seems that the
> main reason is not to include a 2 parameter constructor(Context and
> attributeSet) in the accordion.java. Mine has.
>
> I have made no changes in the java code appart from importing my package ...
>
> This is my AccordionView.java code
>
> package com.egestionamobile.accordionview.widget;
>
>
>
> import java.util.HashMap;
> import java.util.Map;
>
> import android.content.Context;
> import android.content.res.TypedArray;
> import android.util.AttributeSet;
> import android.view.LayoutInflater;
> import android.view.View;
> import android.view.ViewGroup;
> import android.widget.LinearLayout;
> import android.widget.ListView;
> import android.widget.TextView;
>
> import com.egestionamobile.accordionview.utils.FontUtils;
> import com.egestionamobile.accordionview.R;
>
> public class AccordionView extends LinearLayout {
>
>    private boolean initialized = false;
>
>    // -- from xml parameter
>    private int headerLayoutId;
>    private int headerFoldButton;
>    private int headerLabel;
>    private int sectionContainer;
>    private int sectionContainerParent;
>    private int sectionBottom;
>
>    private String[] sectionHeaders;
>
>    private View[] children;
>    private View[] wrappedChildren;
>
>    private Map<Integer, View> sectionByChildId = new HashMap<Integer,
> View>();
>
>    public AccordionView(Context context, AttributeSet attrs) {
> 	    super(context, attrs);
>
> 	    if (attrs != null) {
> 	      TypedArray a = context.obtainStyledAttributes(attrs,
> R.styleable.accordion);
> 	      headerLayo......
> .............
>
>
>
>
> And this is my layout main.axml
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout
>      xmlns:android="http://schemas.android.com/apk/res/android"
>     
> xmlns:accordion="http://schemas.android.com/apk/res-auto/com.egestionamobile.accordionview"
>      android:layout_width="fill_parent"
>      android:layout_height="fill_parent"
>      android:background="@android:color/white"
>      android:orientation="vertical" >
>
>    <ScrollView
>        android:layout_width="fill_parent"
>        android:layout_height="fill_parent" >
>
>      
>      <com.egestionamobile.accordionview.widget.AccordionView
>          android:id="@+id/accordion_view"
>          android:layout_width="fill_parent"
>          android:layout_height="fill_parent"
>          accordion:header_layout_fold_button_id="@+id/fold_button"
>          accordion:header_layout_id="@layout/accordion_header"
>          accordion:header_layout_label_id="@+id/fold_text"
>          accordion:section_bottom="@layout/accordion_footer"
>          accordion:section_container="@layout/accordion_section"
>          accordion:section_container_parent="@id/section_content"
>          
>          android:background="#fff5f5f5"
>          android:orientation="vertical" >
>
>           
>
>            <LinearLayout
>                android:id="@+id/accordion1"
>                android:layout_width="fill_parent"
>                android:layout_height="wrap_content"
>                android:orientation="vertical" >
>           
>            </LinearLayout>
>
>            <LinearLayout
>                android:id="@+id/accordion2"
>                android:layout_width="fill_parent"
>                android:layout_height="wrap_content"
>                android:orientation="vertical" >
>            
>            </LinearLayout>
>
>        </com.egestionamobile.accordionview.widget.AccordionView>
>    </ScrollView>
>
> </LinearLayout>
>
>
>
> Any help please?? Thanks in advance!!!
>
>
>
>
>     
>     
>
>
>
> --
> View this message in context: http://mono-for-android.1047100.n5.nabble.com/Custom-AccordionView-tp5712080.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
>



More information about the Monodroid mailing list