Is there any way to set a custom layout for an error popup window in TextView:
.
In textView.setError(String, Drawable) we can set an error icon only.
showError() method in TextView and ErrorPopup class are private, so I can't work with them.
Any ideas? Thanks in advance! Michael
UPD:
Thanks for comments, but as I understand it, the theme trick isn't applicable here:
(TextView 3384 line from android-10)
void fixDirection(boolean above) {
mAbove = above;
if (above) {
mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error_above);
} else {
mView.setBackgroundResource(com.android.internal.R.drawable.popup_inline_error);
}
}
In android-15 com.android.internal.R.styleable.Theme_errorMessageBackground theme parameter is used, but it is internal.
Therefore I don't see any way to solve this problem, except writing my own error notificator ):
Related
I have customized text view in my android app. And I want to use it with react native. So I follow the guide and write it as:
public class CustomizedTextViewManager extends SimpleViewManager<CustomizedTextView> {
...
}
It works, but can't adjust textview's height based on its content. I have to give a height in render(), otherwise the textview will not be expanded.
What I want is that it can reset its height base on its content, just like what Rn textview did.
render(){
...
<CText style={styles.message} >{message.text}</CText> // CText is the CustomizedTextView
...
}
cosnt styles = ...({
...
message:{
...
height: 100,
}
...
})
Problem is that it looks urgly when there was little content in the textview.
So I look into ReactTextViewManager.java and re-write my view like:
public class CustomizedTextViewManager extends BaseViewManager<CustomizedTextView,ReactTextShadowNode> {
...
}
It shows:
CustomizedTextView has no propType for native prop CustomizedTextView.allowFontScaling of native type boolean
How to fix it? Thanks.
Fixed, my bad.
The error already hints that I should set props like 'allowFontScaling'.
At first I thought I missing implement 'allowFontScaling' in my native manager. But it shouldn't be. The native manager is already the sub-class of Rn text manager, which should implement all props.
Finally in Rn debugger I find that I should add Text.propTypes and View.proTypes in propTypes in 'CText.js'
Solution:
var iface = {
name: 'GSMText',
propTypes: {
myProp1: PropTypes.string,
myProp2: PropTypes.number,
...Text.propTypes, // must add this tow propTypes
...View.propTypes, // other wise will see the red screen
}
}
Hope it will be helpful.
Is is possible to set error on Text Input Layout without showing any error message (i'm already doing it in another place)?.
textinputlayout.setError("");
won't work unfortunately.
What i basically need is the textInputLayout to change its line color to red, but i need to do it programmatically. Thank you
You can hide the layout with error like this:
textinputlayout.setError("");
if (textinputlayout.getChildCount() == 2) {
textinputlayout.getChildAt(1).setVisibility(View.GONE);
}
Hope it's not too late, but the code behind setError is:
if (!mErrorEnabled) {
if (TextUtils.isEmpty(error)) {
// If error isn't enabled, and the error is empty, just return
return;
}
}
this means a simple workaround would be:
textinputlayout.setError(" ");
please be advised, that this will make TextView with error message visible - so it will make TextInputLayout higher even if it will be empty
since this passes the not-so-well-thought-out case of handling an empty error message request.
The error text (even " ") will take/reserve some height in the TextInputLayout. If you also want to get rid of it then
<com.google.android.material.textfield.TextInputLayout
...
app:errorTextAppearance="#style/MyZeroSizeTextAppearance"
...
>
Text appearance:
<style name="MyZeroSizeTextAppearance">
<item name="android:textSize">0sp</item>
</style>
and then
textinputlayout.setError(" ");
I am trying to render a checkbox in a Xamarin Forms app. There is nothing rendered at runtime, as far as I can tell the renderer is not even getting called.
Does anyone understand what I am missing or doing incorrectly?
Here is my class in Forms:
public class LegalCheckbox : View
{
public LegalCheckbox ()
{
}
}
And my custom renderer class in Droid:
public class CheckBoxRenderer : ViewRenderer<LegalCheckbox, CheckBox>
{
protected override void OnElementChanged (ElementChangedEventArgs<LegalCheckbox> e)
{
base.OnElementChanged (e);
CheckBox control = new Android.Widget.CheckBox(this.Context);
control.Checked = false;
control.Text = "I agree to terms";
control.SetTextColor (Android.Graphics.Color.Rgb (60, 60, 60));
this.SetNativeControl(control);
}
}
Along with the Assembly Directive:
[assembly: ExportRenderer(typeof(demo.LegalCheckbox), typeof(demo.Droid.CheckBoxRenderer))]
Took your code and fired up a new project with it. The code appears to function fine.
Only thin I can think that might be causing you an issue is the location of you assembly attribute. I typically place them just above the namespace declaration in the same file as my renderer.
I threw what I created up on my github maybe you can spot the difference.
https://github.com/DavidStrickland0/Xamarin-Forms-Samples/tree/master/RendererDemo
#Thibault D.
Xlabs isn't a bad project but its basically just all the code the opensource community came up with during the first year or so of Xamarin.Forms life. Its not really "Their Labs projects" and considering how much of it is marked up with Alpha Beta and the number of bugs in their issues page it's probably best not to imply that the Xamarin company has anything to do with it.
I am not sure if that is the issue but it would make more sense to me if your LegalCheckbox would inherit from a InputView rather than View.
Also, even if Xamarin.Forms does not have a Checkbox control you can still have a look at their "Labs" project here:
https://github.com/XLabs/Xamarin-Forms-Labs/wiki/Checkbox-Control
(And I can actually see that they inherit from View...)
I am developing soft keyboard every thing works fine but when i change orientation following error occurs
"Unexpected null in startExtractingText : mExtractedText = null, input connection = com.android.internal.view.InputConnectionWrapper"
and close the inputview as well
i don't know how to solve this please help.
I found problem
when External application force close Input-view it will throw
start extracting text null
I have faced the same issue. I have resolved this issue. In my case , I was adding my custom view on overrided method setExtractView(View view). But I was not removing views first.
Let me explain :
#Override
public void setExtractView(View view) {
// You have to do this if you are not doing so
view.removeAllViews() ; // This is the line
view.addView(yourView) ; // Here you can put your own Custom view
super.setExtractView(view);
}
This is working for me.I hope this will help you.
I have been trying very hard to style the text size and colour on android 3.2. When attempting to override the default style with
<item name="android:numberPickerInputTextStyle">#style/numberPickerInputText</item>
I always get this error:
error: Error: No resource found that matches the given name: attr 'android:numberPickerInputTextStyle'.
Why is this so? I am pretty sure I selected the correct style to override (dug it from the platform 13 API folder)
I looked in these places.. seems like it cant be helped!
http://code.google.com/p/android/issues/detail?id=18659#c8
No resource found that matches the given name '#android:style/AlertDialog' error after the latest android 3.2 sdk update
This blog below said something about importing the styles into my application. How is it supposed to be done? examples?
http://daniel-codes.blogspot.com/2011/08/new-to-android-more-style-restrictions.html
Can someone please point me to the right direction? Thanks!
Quick and dirty way.. apply it after you show the dialog. Not a good solution but it works.. still looking for other solutions :)
//Should'nt be here but well..
public static void changeDialogTextSize(Dialog dialog) {
TextView tvMessage = (TextView)dialog.findViewById(android.R.id.message);
if (tvMessage != null)
{
tvMessage.setTextSize(25f);
tvMessage.setTextColor(Color.WHITE);
}
}