Android :: Custom Compound Component Rare Exception

Aug 16, 2009

I've created custom compound component and observe very strange exception (google says nothing about it). Custom component rare exception: Parser is not a BridgeXmlBlockParser!

It is very simple:
public class MyTabber extends LinearLayout {
.. public MyTabber(Context context) { super(context);
Init(context); }

Android :: Custom Compound Component Rare Exception


Android :: Views In Custom Compound Component Not Inflated

Jun 12, 2010

I have made a Custom Component in XML, consisting of a button with an imageview stacked on top of it:

<myapp.widget.ClearableCaptionedButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/ccbutton_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="@android:drawable/edit_text"/>
<ImageView
android:id="@+id/ccbutton_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_alignRight="@id/ccbutton_button"
android:layout_alignTop="@id/ccbutton_button"
android:layout_alignBottom="@id/ccbutton_button"/>
</myapp.widget.ClearableCaptionedButton>

Extract of java source code:
public class ClearableCaptionedButton extends RelativeLayout implements OnClickListener {
...
public ClearableCaptionedButton(Context context, AttributeSet attrs) { super(context, attrs);
// some stuff that works fine
} ..
protected void onFinishInflate() { super.onFinishInflate();
mButton = (Button) findViewById(R.id.ccbutton_button);
mClear = (ImageView) findViewById(R.id.ccbutton_clear);
mButton.setText(""); // error here: mButton == null
}

My problem is similar to this one. When I try to find the views inside the custom compound, findViewById returns null. But, as you can see, i already added super(context, attrs); to the constructor. I am using the custom component directly in xml layout, like this:

<LinearLayout>
<!-- some stuff -->
<myapp.widget.ClearableCaptionedButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:caption="to"/>
</LinearLayout>

View 1 Replies View Related

Android :: Android - Writing Custom (Compound) Component

Sep 25, 2009

The Android app I'm currently developing has a main activity that has grown quite large. This is mainly because it contains a TabWidget with 3 tabs. Each tab has quite a few components. The activity has to control of all those components at once. So I think you can imagine that this Activity has like 20 fields (a field for almost every component). Also it contains a lot of logic (click listeners, logic to fill lists, etc). What I normally do in component based frameworks is to split everything up into custom components. Each custom component would then have a clear responsibility. It would contain it's own set of components and all other logic related to that component.

I tried to figure out how this can be done, and I found something in the Android documentation what they like to call a "Compound Control".
(See http://developer.android.com/guide/topics/ui/custom-components.html and scroll to the "Compound Controls" section) I would like to create such a component based on an XML file defining the view structure.

In the documentation it says:
Note that just like with an Activity, you can use either the declarative (XML-based) approach to creating the contained components, or you can nest them programmatically from your code. Well, that's good news! The XML-based approach is exactly what I want! But it doesn't say how to do it, except that it is "like with an Activity". But what I do in an Activity is call setContentView(...) to inflate the views from XML. That method is not available if you for example subclass LinearLayout. So I tried to inflate the XML manually like this:

public class MyCompoundComponent extends LinearLayout {
public MyCompoundComponent(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.my_layout, this);
} }

This works, except for the fact that the XML I'm loading has LinearLayout declared as the root element. This results in the inflated LinearLayout being a child of MyCompoundComponent which itself already is a LinearLayout!! So now we have a redundant LinearLayout in between MyCompoundComponent and the views it actually needs. Can somebody please provide me with a better way to approach this, avoiding having a redundant LinearLayout instantiated?

View 1 Replies View Related

Android :: Java Rare And Impossible Exception Causing Force Close

Apr 19, 2010

I have an interesting problem being reported to me from an android application I have published. I have a two-dimensional array that I am iterating through using two for loops like so:

for (int i = 0; i < arr.length; ++i)
{
for (int j = 0; j < arr[i].length; ++j)
{
if (arr[i][j] != 0)
// does stuff
}
}

The problem is, somehow arr[i][j] != 0 is throwing an ArrayIndexOutOfBoundsException. But very rarely. I have thousands of people use the app on a daily basis and get maybe twenty force close reports. Is this something I can't avoid, maybe a problem with the phones memory, etc. or is there something I can do that I haven't thought of yet?

View 1 Replies View Related

Android :: XML Layout Of Custom Component

Jul 9, 2010

I have created a simple class named Panel which extends the SurfaceView class and does some drawing in the onDraw method. When I use it from the code it works fine. For example this works as expected:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new Panel(this)); ....

However when I try adding this component from an xml layout the program crashes:
XML file (main.xml):
<?xml version="1.0" encoding="utf-8"?> <org.anddev.Panel android:id="@+id/panel" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"/>

Code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);....

Error msg: Sorry!
The application Test (process org.anddev) has stopped unexpectedly. Pleas try again.
I can not figure out why the same class works when created in one way and doesn't work when created in another.

View 3 Replies View Related

Android :: Create Custom Component Using Inflate

Mar 29, 2010

I'm trying to create a component using an xml layout file. I defined a layout with some custom attributes. This layout is inflated when user add it inside another layout. My problem is I don't know the parent, so I pass null for the parent viewgroup when I call inflate method. I think that's the reason why I see anything in my view. Do you know how can I do (I don't want to redefine onDraw method because I use existing component). Below my xml layout and my custom class.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView android:id="@+id/img_btn_option" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<TextView android:id="@+id/txt_btn_option" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toRightOf="@id/img_btn_option"
android:textColor="@color/font_white" android:textStyle="bold"/>
</RelativeLayout> public class ButtonOptionsView extends View {
public ButtonOptionsView(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater li =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout vg =(RelativeLayout)li.inflate(R.layout.button_option, null);
TypedArray ta = getContext().obtainStyledAttributes(attrs,R.styleable.ButtonOption);
((ImageView)vg.findViewById(R.id.img_btn_option)).setImageResource(ta.getResourceId(R.styleable.ButtonOption_image,0));
((TextView)vg.findViewById(R.id.txt_btn_option)).setText(ta.getResourceId(R.styleable.ButtonOption_text,0));}

View 4 Replies View Related

Android :: Custom Component ImageView Override

Dec 8, 2009

I've made a little test component that overrides ImageView, called myImageView, and prints some text and an arrayList of Doubles over whatever image is specified in the related xml. However, right now, the text and Doubles that are drawn over the image are defined within the myImageView class. Is there a way to pass the data from the main onCreate function to the myImageView class before the layout is drawn?

I'm new to OO programming, but based on my understanding of this:
http://developer.android.com/guide/topics/ui/custom-components.html
It's possible because ImageView is just like any other class. This leaves me with two initial guesses:
1. I could generate my test data in the main onCreate, and store it in the array's xml file, and then read that xml file with myImageView,
OR
2. I could extend view instead of ImageView, but because of my new- ness, then I would lose the ability to use it in an xml layout sense - and that's what I really want.

View 2 Replies View Related

Android :: How To Change Custom Component Height Programmatically?

Dec 9, 2009

I've prepared custom component based on LinearLayout. Whole component is defined in XML. Currently to use it you have to write:
<com.xxx.android.components.TopMenu
android:layout_width="fill_parent"
android:layout_height="44dp" />

Is it possible to set width and height in the java constructor? So it would be possible to write just:
<com.xxx.android.components.TopMenu />
I've tried to modify and set LayoutParams, but it didn't work for me.

View 1 Replies View Related

Android :: Creating Custom Component Which Supports Voice Recognition

Jun 11, 2010

I'd like to create a custom component which supports voice recognition. (Custom Component which displays voice recognition button if available). It will primarily be an extended EditText which should show the microphone button for voice recognition if it is available. I wanted to to look at the search app-widget on the homescreen but I don't find it in the source. This is intended to use the voice recognition as some sort of dictation device, i.e. the user does not have to type but use his voice instead. So could anyone please point me in some direction?

View 1 Replies View Related

Android :: Expanding ListView Custom Component With Button Click

Nov 5, 2010

I'm developing a small application in with a list view filled with a compound component. This component has two text view and one button inside. One of the text view is invisible and when the button is clicked it should appear. I can show the list but i can't make the textview visible when the button is clicked. Here is the xml of the component: And this is the ArrayAdapter that fills the list:

public class AddressAdapter extends ArrayAdapter { int resource;
RelativeLayout placeView;
EditText addressText;
public AddressAdapter(Context _context, int _resource, List _items) {
super(_context, _resource, _items);
resource = _resource;
} private OnClickListener buttonClick = new OnClickListener() {
public void onClick (View v) {
int i = placeView.findViewById(R.id.stub_import).getVisibility();
visibility(i);
} };
private void visibility(int i) {
// TODO Auto-generated method stub switch(i) {
case(View.GONE): { addressText.setVisibility(View.VISIBLE);
} case(View.VISIBLE): { addressText.setVisibility(View.GONE);
} } }
@Override public View getView(int position, View convertView, ViewGroup parent) {
Item item = getItem(position);
String name = item.getName();
String address = item.getAddress();
if (convertView == null) {
placeView = new RelativeLayout(getContext());
String inflater = Context.LAYOUT_INFLATER_SERVICE;
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(inflater);
vi.inflate(resource, placeView, true);
} else { placeView = (RelativeLayout) convertView;
} TextView nameText = (TextView)placeView.findViewById(R.id.placeNamwView);
Button button = (Button)placeView.findViewById(R.id.Button01);
addressText = (EditText)placeView.findViewById(R.id.placeAddressText);
button.setOnClickListener(buttonClick);
nameText.setText(name);
addressText.setText(address);
return placeView;
} }

View 2 Replies View Related

Android :: Including Custom Component / View No Longer Shows Up

Oct 29, 2009

The app I'm working on has 4 tabs, 3 of which share many features, including a navigation bar a the bottom with Back, Edit, and Map buttons. There is exactly the same xml in all 3 layouts, so I'm trying to DRY this out by extracting that xml into a separate component, including it, and then going from there. Previously I had:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/showedit_toolbar" style="@style/showItemToolbar">
<ImageButton android:id="@+id/show_person_back_button"
style="@style/blackToolbarButton"
android:src="@drawable/left_white_arrow"
android:layout_alignParentLeft="true"/>
<Button android:id="@+id/show_person_map_button"
style="@style/blackToolbarButton"
android:text="map" android:layout_alignParentRight="true"/>
<Button android:id="@+id/show_person_edit_button"
style="@style/blackToolbarButton"
android:text="edit" android:layout_toLeftOf="@id/show_person_map_button"/>
</RelativeLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_above="@id/showedit_toolbar"
style="@style/CoinLightTheme">
// Lots more layout omitted

I extracted out the bit that's repeated into an xml file called show_toolbar.xml, changing the names of variables to make it more generic across the 3 views
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/show_toolbar" style="@style/showItemToolbar">
<ImageButton style="@style/blackToolbarButton"
android:src="@drawable/left_white_arrow"
android:layout_alignParentLeft="true"
android:id="@+id/show_back_button"/>
<Button android:id="@+id/show_map_button"
style="@style/blackToolbarButton"
android:text="map" android:layout_alignParentRight="true"/>
<Button android:id="@+id/show_edit_button" style="@style/blackToolbarButton"
android:text="edit" android:layout_toLeftOf="@id/show_map_button"/>
</RelativeLayout>

Then from within my original layout file, I replaced that big block of code with
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<include android:id="@+id/show_toolbar" layout="@layout/show_toolbar"/>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_above="@id/showedit_toolbar" style="@style/CoinLightTheme">

Now, the problem is that the view no longer shows up. Including Custom component causes it to be hidden behind main viewI can still click the buttons and they respond (i.e. if I click in the corner where the button should be, it still works), but I cannot see the buttons or bar onto which they were drawn. I cannot find very good documentation on how Include is supposed to work, so perhaps I am using it incorrectly.

View 1 Replies View Related

Android :: Find View Returns Null For Custom Component In Layout

Nov 7, 2009

I have a res/layout/main.xml including these elements and others:

<some.package.MyCustomView android:id="@+id/foo" (some other params) />
<TextView android:id="@+id/boring" (some other params) />
In my Activity's onCreate, I do this:
setContentView(R.layout.main);
(TextView) boring = findViewById(R.id.boring);
// ...find other elements...
MyCustomView foo = (MyCustomView) findViewById(R.id.foo);
if (foo == null) { Log.d(TAG, "epic fail"); }

The other elements are found successfully, but foo comes back null. MyCustomView has a constructor MyCustomView(Context c, AttributeSet a) and a Log.d(...) at the end of that constructor appears successfully in logcat just before the "epic fail".
findViewById() returns null for custom component in layout XML, not for other components. Why is foo null?

View 2 Replies View Related

Android :: Android - Showing Dialog From Custom Component

Jun 15, 2010

I am writing a custom component (derived from a relative layout) which has to show a dialog. Is there a way to do this using callbacks like oncreatedialog or onpreparedialog? if not: if i have to create the dialog outside oncreatedialog, i have to "attach it to an Activity with setOwnerActivity(Activity)". How can the custom component access the activity it is used in, when it is used in the activity's xml-layout and not created from code?

View 1 Replies View Related

Android :: Android - Defining Custom Component Layouts In XML

Oct 5, 2010

I'm reading the android developer docs on creating custom components and one thing that's unclear, is whether you can define the layout of your component using xml and then reuse that across class libraries. like, say for instance, I want to create a class library called myComponents, and in there i want to have myTehAwesumsWidget or whatever, and i want the layout to be defined in xml, can i include that xml in the referenced class library?

View 1 Replies View Related

Android :: OOM Exception With Custom Imageadapter

Apr 26, 2010

I have a gallery in wich I show a row of images, the images can both be from the Camera gallery or from the internet as a web url. My getView() method makes an exception when I put to many images from the gallery inside it. Should i down sample the images before attaching them to the view? and how is that done ?

Heres my getView method:

CODE:........................

View 3 Replies View Related

Android :: Display A Custom Exception In An Alert?

Dec 22, 2009

I would like to know if there exists a way to listen for a custom exception in Android and display its text using an alert.

View 2 Replies View Related

Android :: Android Custom Component Properties

Feb 2, 2010

I have made an component for Android, which uses two drawables. Using static values for the drawables in the code, the component works but now I want to declare the values in the properties (XML) does anyone know how to do this? Is there a way to do this without using the attrs.xml?

View 1 Replies View Related

Android :: SDK - Throw A Custom Exception From A Service To An Activity

Nov 26, 2009

I'm currently working on an XMPP app' on Android and I'm pondering about the best way to throw a different type of Exception than a RemoteException to my activity from my service.

As it seems impossible to throw another thing than a RemoteException using IPC (you can't declare to throw anything in your .aidl), I just see two solutions:

Create a listener for my activity to listen on my custom XMPP exception, which in fact will not be thrown but just sent as a usual object implementing the Parcelable protocol.
Catch my XMPPException and throw a RemoteException (with a content updated with my XMPPException) - But in that case, how could I know on my activity if it's an XMPP or a real RemoteException ? By tagging the name of the exception and parsing it on my activity ? It would be really gore.

View 2 Replies View Related

Android :: Class Cast Exception When Inflating A Custom Relative Layout

Jul 23, 2010

I get this exception when I try to inflate

07-22 19:15:39.903: ERROR/AndroidRuntime(3810): Caused by: java.lang.ClassCastException: android.widget.RelativeLayout

I have a base class:

public class UIBase extends RelativeLayout {}

And a more specific class:

public class Countdown extends UIBase {}

Then I try to inflate and it exceptions:

UIBase newView = (UIBase) inflater.inflate(layoutId, parent, true);

Here's the XML file:

CODE:..................

View 1 Replies View Related

Android :: Sqlite Exception:java.lang.Illegal Argument Exception Column Id Does Not Exist

Jul 14, 2010

I created a sql lite database with the following columns:
static final String dbName="demoDB";
static final String tableName="Employees";
static final String colID="EmployeeID";
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE "+tableName+" ("+colID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+
colName+" TEXT, "+colAge+" Integer);");
I want to select all the records in the database like this and display them in a gridview:SQLiteDatabase db=this.getWritableDatabase();Cursor cur= db.rawQuery("Select "+colName+", "+colAge+" from "+tableName, new String [] {});String [] from=new String []{DatabaseHelper.colName,DatabaseHelper.colAge};
int [] to=new int [] {R.id.colName,R.id.colAge};
SimpleCursorAdapter sca=new SimpleCursorAdapter(this,R.layout.gridrow,c,from,to);
GridView grid=(GridView)findViewById(R.id.grid);
grid.setAdapter(sca);but i receive the following exception:java.lang.IllegalArgumentException: column '_id' does not exist.the db table does not have a column with name '_id'so what is wrong with this code

View 3 Replies View Related

Android :: Space Between Component

Aug 20, 2009

I am putting one spinner and one button using following code. Can some one tell me how can i put some space between it?

View 4 Replies View Related

Android :: Use Of Service Component?

Aug 31, 2010

Service Component is used to do some task which can be done without user interaction. But for that we have to run a thread in subclass of the Service. I think we can create a thread in Activity class itself then what is the use of Service component? Why don't we create another thread and write the non interacting code in this thread.

View 10 Replies View Related

Android :: Unlock Key Component

Apr 30, 2010

I have almost completed my Android application so am considering ways of distributing the application. I have seen some applications on Market have free limited/locked version and separate Unlock Key/License Key which unlocks extra functionality. How is this done? Has anyone here done this? If so, how well does it work? I am thinking maybe this is better then having two versions of the same application (i.e Lite and Pro).

View 1 Replies View Related

Android :: CustomSpinner Component ?

Nov 18, 2010

I've created a custom component which works like a lock of a safe. customspinner - Project Hosting on Google Code on picture you see two different objects of my component.

If you need to create UI when user need to choose some element of a list, using this non standard component will be more intresting for user. And it is usefull - user can scroll and find a needed value very quickly.

View 4 Replies View Related

Android :: Component ClassNotFoundException ?

Jan 11, 2010

A component I have created works fine if I put it in the main project and reference it from any res/layout xml, but when I put it in a project on which the main project depends, I get a ClassNotFoundException in the xml.

Whilst after compiling the interface works fine, it is a pain in the * to design an interface without seeing what I am doing because of the error. Does anyone know how to solve it?

Stacktrace:

CODE:.........................

View 2 Replies View Related

Android :: New OMX Component Integration Into Opencore

Aug 2, 2010

I am trying to integrate VP8 video codec into PV opencore FW in Froyo & test at PV test application level. I have done the following steps, 1. Made a new folder for vp8 @ external/opencore/codecs_v2/omx/ omx_vp8. 2. Made appropriate modifications in the omx_baseclass, omx_common etc. 3. Modified the PV test app (external/opencore/codecs_v2/omx/ omx_testapp) for testing VP8. 4. included the VP8 source code to froyo. 5. Included new oscluuid for VP8 With these modifications, the build is fine. The shared libraries and binaries are creating properly. Also OMX-MasterInit is passing. But the application fails at OMX_GetHandle(). *pHandle is coming as zero. I am using the PV OMX core. I am just adding a new codec which is not supported by PV Opencore and test at PV test_app level.Can you please answer my below queries: 1. Do we need to change the pvplayer.cfg file? Bcoz i am using the PC omx_core itself. 2. Any other changes needs to be done for integrating a new component into Opencore? Please provide you valuable inputs. Let me know if need any additional informations.

View 4 Replies View Related

Android :: Best Practices For Library With UI Component

Jun 26, 2009

My company is in the process of evaluating if we can add support for Android to our product. I am currently working on porting our existing J2ME library to the Android framework and I have a question regarding our UI component. Right now, we have a custom menu that we allow our developers to bring up on the device. On J2ME, we simply have a single call that the developer makes to enter into the menu and then we handle the rest. On Android, it seems the best way to handle this is an Activity. But I have a few questions regarding this approach including is the really the best way to do something like this? Second, if it is, if there are multiple applications on the device that are using our library, are there going to be conflicts with them all having the same Activity embedded in them? Is it possible to create an Actvity at runtime and use it directly? Would there be any side effects of going about it this way?

View 2 Replies View Related

Android :: Share Component As APK File

Feb 14, 2009

I am working on couple android applications which share a common component. The component has Activities, Service and own AndroidManifest.xml. After research, it seems there is no concept of run time share library among applications in Android. So I am looking for a way to linked the share component with other applications at compile time. Applications which will use the component can come from external, therefore I will only provided the compiled file. I would like to build the component into own apk or jar file, can external application include my jar/apk file into their package and be able to start my activity? Please share your experience and advice.

View 3 Replies View Related

Android :: A Calendar UI Component / Widget

May 27, 2010

I am looking for a calendar UI. Something like the Calendar UI of the Calendar Android Application but only with the view. (I know that's open source so I can extract the UI but it's a long process to remove all the staff unnecessary) Is there any open source Calendar UI project for android ?

View 2 Replies View Related

Android :: Make Customized UI Component

Mar 9, 2010

IN our current project, I need to make a UI describled as follows.

Basically it is a text input, it will display a string returned from server , such as "I like banana". The word "banana" will be in red color. When user clicks "banana", it will have a dropdown list shows "apple, orange, pear". User would be able to select one of them, like apple. So the text in that UI would be "I like apple".

How could I build such a UI component in Android.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved