android - How do I add a custom view to ViewFlipper -


i have viewflipper defined contains 3 views...

<?xml version="1.0" encoding="utf-8"?> <viewflipper xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/flipper" android:layout_width="fill_parent" android:layout_height="fill_parent">   <include android:id="@+id/first" layout="@layout/first_view" />   <include android:id="@+id/second" layout="@layout/second_view" />   <include android:id="@+id/third" layout="@layout/third_view" /> </viewflipper> 

i have custom view defined within activity...

private class compassview extends view {    @override    protected void ondraw(canvas canvas) {   ...   } } 

some how, need these linked 'third_view' defined in xml layout file needs compassview, or have compassview added it.

what can drop 'third_view' layout , add in compassview manually..

viewflipper = (viewflipper)findviewbyid(r.id.flipper); viewflipper.addview(new compassview(this)); 

but lose ability define other view controls within layout file.

can add compassview 'third_view' declaratively?

if question how add custom view in android xml layout file, try this:

<com.example.customview     android:layout_width="fill_parent"     android:layout_height="wrap_content"> </com.example.customview> 

the open , close tags should qualified class of custom view.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -