Overwriting Elements created from XML ?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Overwriting Elements created from XML ?

Postby pmws » Thu Sep 24, 2009 12:35 pm

Hi,

Lets say I have a View that was created in XML like this :
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <View android:id="@+id/View01" android:layout_width="wrap_content" android:layout_height="wrap_content"></View>
  3.  
  4.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4



Now in Java I put it in a Variable, like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. View v = (View) findViewById (R.id.View01);
  3.  
  4.  
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


Is there any way to overwrite the onDraw Method for this View or can I only do that when I am creating the View directly in Java ?

thx in advance,

Paul
(oh and xcuse my bad english) :)
pmws
Developer
Developer
 
Posts: 37
Joined: Thu Sep 24, 2009 12:23 pm

Top

Postby wiederke » Fri Sep 25, 2009 12:13 pm

Hi,

I you want to overwrite the onDraw method you have to derive from the View class and override the onDraw method in your class. If your class name is myview.DerivedView you can use it like this in xml.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <myview.DerivedView android:id="@+id/View01" android:layout_width="wrap_content" android:layout_height="wrap_content"></myview.DerivedView >
Parsed in 0.001 seconds, using GeSHi 1.0.8.4



cu,

Torsten
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests