Note that there are some explanatory texts on larger screens.

plurals
  1. POExtended EditText class wont instantiate
    primarykey
    data
    text
    <p>I'm trying to extend the EditText class but I can't seem to get it to work. I've created this class in my public class MainActivity extends Activity as a sub class:</p> <pre><code>public class EditText2 extends EditText { public EditText2(Context context) { super(context); // TODO Auto-generated constructor stub } public EditText2(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } public EditText2(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } } </code></pre> <p>and tried hand coding and using the Graphical Layout tab in Eclipse to edit the activity_main.xml to add the new class as such:</p> <pre><code>&lt;first.words.firstwords.MainActivity.EditText2 android:id="@+id/user_input" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:text="EditText2" &gt; &lt;requestFocus /&gt; &lt;/first.words.firstwords.MainActivity.EditText2&gt; </code></pre> <p>But I get:</p> <blockquote> <p>java.lang.NullPointerException at com.android.layoutlib.bridge.impl.RenderSessionImpl.getDefaultProperties(RenderSessionImpl.java:1476) at com.android.layoutlib.bridge.BridgeRenderSession.getDefaultProperties(BridgeRenderSession.java:68) at com.android.ide.eclipse.adt.internal.editors.layout.gle2.ViewHierarchy.getDefaultProperties(ViewHierarchy.java:710) at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlProperty.getStringValue(XmlProperty.java:209) at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlProperty.getValue(XmlProperty.java:221) at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlPropertyEditor.getText(XmlPropertyEditor.java:116) at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlPropertyEditor.paint(XmlPropertyEditor.java:131) at org.eclipse.wb.internal.core.model.property.table.PropertyTable.drawProperty(PropertyTable.java:1309) at org.eclipse.wb.internal.core.model.property.table.PropertyTable.drawContent(PropertyTable.java:1151) at org.eclipse.wb.internal.core.model.property.table.PropertyTable.handlePaint(PropertyTable.java:1094) at org.eclipse.wb.internal.core.model.property.table.PropertyTable.access$200(PropertyTable.java:64) at org.eclipse.wb.internal.core.model.property.table.PropertyTable$3.handleEvent(PropertyTable.java:187) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1300) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1285) at org.eclipse.swt.widgets.Control.gtk_expose_event(Control.java:2992) at org.eclipse.swt.widgets.Composite.gtk_expose_event(Composite.java:709) at org.eclipse.swt.widgets.Canvas.gtk_expose_event(Canvas.java:167) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1769) at org.eclipse.swt.widgets.Control.windowProc(Control.java:5116) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4377) at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8317) at org.eclipse.swt.widgets.Display.eventProc(Display.java:1193) at org.eclipse.swt.internal.gtk.OS._gdk_window_process_all_updates(Native Method) at org.eclipse.swt.internal.gtk.OS.gdk_window_process_all_updates(OS.java:5571) at org.eclipse.swt.widgets.Display.update(Display.java:4330) at org.eclipse.swt.widgets.Display.runDeferredLayouts(Display.java:3588) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3173) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) at org.eclipse.equinox.launcher.Main.run(Main.java:1438) at org.eclipse.equinox.launcher.Main.main(Main.java:1414)</p> </blockquote> <p>from the activity_main.xml and ClassNotFoundException when I run the application. I've googled around and looked at <a href="https://stackoverflow.com/questions/7648924/extending-a-edittext-in-android-what-do-i-do-wrong">Extending a EditText in Android. What do I do wrong?</a> and <a href="https://stackoverflow.com/questions/7518573/whats-the-right-way-to-extend-edittext-to-give-it-additional-default-function">What's the right way to extend EditText to give it additional “default” functionality</a> among others to no avail.</p> <p>Can anyone see where I've gone wrong as I've spent hours looking myself and can't see it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload