You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement android.widget.EditText using GtkEntry
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class EditText extends TextView {
|
||||
public EditText(Context context) {
|
||||
@@ -12,4 +12,50 @@ public class EditText extends TextView {
|
||||
public EditText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected native long native_constructor(Context context, AttributeSet attrs);
|
||||
protected native String native_getText(long widget);
|
||||
|
||||
public Editable getText() {
|
||||
return new FIXME_Editable(native_getText(widget));
|
||||
}
|
||||
|
||||
public Editable getEditableText() {
|
||||
return new FIXME_Editable(native_getText(widget));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(CharSequence text) {}
|
||||
@Override
|
||||
public void setTextSize(float size) {}
|
||||
|
||||
private class FIXME_Editable implements Editable {
|
||||
private String string;
|
||||
|
||||
public FIXME_Editable(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return string.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char charAt(int index) {
|
||||
return string.charAt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return string.subSequence(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TextView extends View {
|
||||
@Override
|
||||
protected native long native_constructor(Context context, AttributeSet attrs);
|
||||
|
||||
public final void setText(CharSequence text) {
|
||||
public void setText(CharSequence text) {
|
||||
if (text == null) {
|
||||
native_setText("NULL");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user