When I scroll recyclerview, I found an issue - android-studio-3.0

When I scrolls recyclerview using addonScrolllistener, the below method called only one time. Why is this?
#Override
public void onScrolled(#NonNull RecyclerView recyclerView, int dx, int dy) {
}

Related

Xamarin Form slider customisation for changing the thickness of slider bar in iOS

Want to customise the ios slider to increase the thickness of slider bar. i tried using scaling but it is scaling the whole slider including the thumbimage and text above slider.
There are two ways to implement this.
MessagingCenter
Create delegate for the custom slider and trigger it in CustomRenderer.
Code:
MySlider
public class MySlider : Slider
{
public delegate void SlideEventHandler(double newValue);
public SlideEventHandler SlideEvent;
}
Page
public Page1 ()
{
InitializeComponent ();
slider.SlideEvent += slideChange;
}
void slideChange(double newValue) {
Debug.WriteLine(newValue);
}
MySliderRenderer
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
{
MySlideriOS slider = new MySlideriOS();
slider.ValueChanged += Slider_ValueChanged;
SetNativeControl(slider);
base.OnElementChanged(e);
}
private void Slider_ValueChanged(object sender, EventArgs e)
{
MySlideriOS slider = sender as MySlideriOS;
(Element as MySlider).SlideEvent(slider.Value);
}

EditText content size vs layout size

I have a singleline EditText, and I am interested in the size of the content vs the size of the EditText, to see if the content fits the size of the EditText or not. How can I do this?
Thanks
I'm not really sure what you are asking here:
You can measure the text width like this: (taken from Alan Jay Weiner here:Auto Scale TextView Text to Fit within Bounds)
// Set the text size of the text paint object and use a static layout to render text off screen before measuring
private int getTextWidth(CharSequence source, TextPaint paint, int width, float textSize) {
// Update the text paint object
paint.setTextSize(textSize);
// Draw using a static layout
StaticLayout layout = new StaticLayout(source, paint, width, Alignment.ALIGN_NORMAL, mSpacingMult, mSpacingAdd, true);
layout.draw(sTextResizeCanvas);
return layout.getWidth();
}
and you can measure the text as its changed with a watcher like this:
yourEditText.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
//measure your stuff here
}
#Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});

control screen orientation blackberry

I want to display an alert in every time when the user change the orientation of the mobile. There is a method to capture this mouvement?
I use Display.getOrientation();. But it always returns 32 in different orientation.
You get a call to sublayout() when orientation changes. You can save the displaywidth to a variable, and if the value has changed in sublayout() , you know the orientation has changed.
like this.
protected void sublayout(int width, int height) {
if(Display.getWidth()==oldWidth)
{
//no change
}
else
{
// orientation changed
}
oldWidth = Display.getWidth();
super.sublayout(width, height);
}
Note: when you check orientation you have to close SLIDER in 9800 simulator other wise it wont work
try following code :
public class checkOrientation
{
VerticalFieldManager manager;int ori;
public checkOrientation()
{
ori=Display.getOrientation();
manager=new VerticalFieldManager()
{
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(Display.getWidth(),Display.getHeight());
setExtent(Display.getWidth(),Display.getHeight());
if(ori!=Display.getOrientation()){
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
ori=Display.getOrientation();
Dialog.inform(""+Display.getOrientation());
}
});
}
}
};
add(manager);
}
}

How to change row color background in a ListField after navigation Click?

I'm beginner in BB dev. I create a CustomListField and when I click on a row, the background color of this row must change and a new screen must be displayed (it's done!).
Could any one please help me to get this done?
thx
Below is the code:
protected boolean navigationClick(int status, int time)
{Field field = this.getLeafFieldWithFocus();
if(field instanceof ListField)
{
// listValues is String[] where you store your list elements.
// listField is the ListField instance you are using
UiApplication.getUiApplication().pushScreen(new ReadMsgScreen());
int index= getIndex();
if(index== this.getSelectedIndex())
{
**// I think the code to change the row's background color must be set here!**
}
return true;
}
return super.navigationClick(status, time);
}
use this it will definately work...
int tmpcolor = graphics.getColor();
graphics.setColor(Color.CYAN);
graphics.fillRect(0, y, width, getRowHeight());
graphics.setColor(tmpcolor);
thanks...
onerride the paint() method in blackberry as showed the code below..
_specialNumbers = new LabelField(Constants.SPECIAL_NUMBERS,LabelField.USE_ALL_WIDTH) {
protected void paintBackground(Graphics arg0) {
int color = arg0.getBackgroundColor();
arg0.setBackgroundColor(Color.LIGHTGREY);
arg0.clear();
arg0.setBackgroundColor(color);
}
};
In the drawListRow() method of the ListFieldCallback for your CustomListField draw that selected line differently and call a Transition to display the other Screen slowly.

Blackberry setting the position of a RichtextField in FullScreen

I am writing an application in BlackBerry, where I want to do some custom painting at the top portion of the screen in the paint method of FullScreen and at the same time, I want a RichtextField positioned at the lower portion of the screen. I tried using setPosition methods in the Field class, but to no avail. So how do I set the position of the RichtextField that is added to the FullScreen class?
You can use a SpacerField for that purpose:
class SpacerField extends Field {
int localWidth, localHeight;
SpacerField(int width, int height) {
super(Field.NON_FOCUSABLE);
localWidth = width;
localHeight = height;
}
protected void layout(int width, int height) {
// TODO Auto-generated method stub
setExtent(localWidth, localHeight);
}
protected void paint(Graphics graphics) {
}
public int getPreferredWidth() {
return localWidth;
}
public int getPreferredHeight() {
return localHeight;
}
}
and add it to your Screen before your RichTextField. Be sure to give a suitable width (Display.getWidth() ?) and height when constructing the SpacerField.
Note: I had found the code at this forum discussion a few months ago when I needed to do something similar.
The best way to position objects is to extend a Manager and use it to position and size the objects the way you want. Check the documentation for net.rim.device.api.ui.Manager and net.rim.device.api.ui.Field for information on how manager control their children.

Resources