I have a webview containing some text. I need to be able to swipe on the webview and make text selection at the same time. The problem is after I have implemented the swipe overriding the onTouchEvent method, the other features of the webview seem to have freezed, links in the webview aren't clickable anymore, and the text selection (after longClick) doesn't work anymore, I need to make to implement the swipe and preserve the other features of the webview.
I tried to override the longClick click method as well and use the following method to implement text selection:
public void selectAndCopyText() {
try {
Method m = WebView.class.getMethod("emulateShiftHeld", null);
m.invoke(MyWebView.this, null);
}
catch (Exception e1) {
e1.printStackTrace();
KeyEvent shiftPressEvent = new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(this);
}
}
but it didn't work for when this method is called I only get the upper bar for copy/ paste/ search/ websearch... but no actual selection on the webview occur.
Related
I am trying to show my long text on Navigation Bar in 2 lines. I am using LargeTitles.
What I need is this https://i.stack.imgur.com/Yb85L.png // sorry cant post picture.
Image was taken from this post
I have tried a lot of examples and have achieved in showing the title in 2 lines. but the problem is that when I open a ViewController with a long title it jumps to adjust the title. Following is my code I have tried. I want to avoid jumping (increasing) and show the multiline text as same as it if using single line text. the normal effect.
func multiLineHeader() {
if #available(iOS 11.0, *) {
if let subviews = self.navigationController?.navigationBar.subviews {
for navItem in subviews {
for itemSubView in navItem.subviews {
if let largeLabel = itemSubView as? UILabel {
if largeLabel.canFitInSingleLine() { return }
largeLabel.numberOfLines = 2
largeLabel.lineBreakMode = .byWordWrapping
largeLabel.sizeToFit()
self.navigationController?.navigationBar.frame.size.height += largeLabel.frame.height
self.navigationController?.navigationBar.layoutIfNeeded()
}
}
}
}
}
}
I am calling this from viewDidAppear(). I tried calling from viewDidLoad() and viewWillAppear() does not work event title is not in 2 lines. as it was when called from viewDidAppear().
If there is anything which is not clear, comment and I will add more details.
This is not a solution to solve the multiline jump effect.
My question was based on the multiline title which I saw in the App Store(app) which did not have a jump effect. After a while when I dig deep into it. I found out that even in the App Store there is a jump effect on some screens and in some places App Store is using view rather than navigation bar.
For example, if you go to the App Store and search for Thunderbox entertainment.
1) Go to one of its apps and then click on company name to see all apps you will see a navigation bar with jump effect.
2) If you open the company profiles directly from the search screen you won't see any jump effect.
I have single view layout with edit text and image. To display data in listview i am using arrayadapter . While entering value in Edit text in first row. The data gets repeated to another row in listview . How can i resolve this ?
View rowView = null;
try {
if (convertView == null) {
//inflating view.
rowView =
inflater.inflate(R.layout.list_single_view,null,false);
}
else
{
//Setting view if layout is already implemented.
rowView = convertView;
}
imageView = (ImageView)
rowView.findViewById(R.id.iv_activity_image_single);
//Facing issue here in editText . The entered text gets repeated
et_image_name = (EditText)
rowView.findViewById(R.id.txt_user_notes);
et_image_description = (EditText)
rowView.findViewById(R.id.txt_user_description);
//Loading image using universal image loader to imageView
if (equipmentPicturesList.get(position) != null) {
Constant.imageLoader.displayImage("file:///" +
equipmentPicturesList.get(position).toString(), imageView, Constant.options,
new SimpleImageLoadingListener());
}
else {
imageView.setBackgroundResource(R.drawable.ic_launcher);
}
}
catch (Exception e) {
Logger.loadStackTrace(e);
}
return rowView;
The EditText messes with the focus of whatever layout it is in. That can be a little tricky by itself, but in a ListView it causes all sorts of problems. But there is a way around that, it will work if you put the EditText inside the footer or header of the ListView with addHeaderView or addFooterView. The reason that it works in the header or footer is that the header and footer views are not recycled by the ListView. Alternatively you can call setHasTransientState() on the EditText to prevent it from being recycled even as a normal view inside the ListView.
But beware that turning off the view recycling - especially if you do it for multiple views - can impact performance and scrolling speed of the ListView.
I'm doing some MonoTouch development, and I really can't figure out an problem I've run into
I'm having an ViewController containing a UIButton. I have added a delegate to the TouchDown event of this button. In this delegate I'm calling a WebService and trying to change the colour and title of the button. However nothing happens to the button before the entire delegate have been executed. The thing is that the webservice is rather slow, so I want to give the users a waiting message by changing the colour and title of the button.
The code:
public override void ViewDidLoad ()
{
View.BackgroundColor = UIColor.Black;
bookButton = new UIButton( new RectangleF(10,100,this.View.Frame.Width-10 ,40) );
bookButton.BackgroundColor = UIColor.Clear;
setButton();
bookButton.TouchDown += delegate {
gymClass.book();
setButton();
tableView.ReloadData();
NavigationController.PopViewControllerAnimated( true );
};
this.View.AddSubview( bookButton );
}
Anyone, please?
The delegate is executed on the main thread which is responsible for rendering, so you are blocking the renderer until you return.
I have an Activity that populates two views on a ViewFlipper. I added an onTouch(View v, MotionEvent event) public boolean method to the Activity. The method is implemented so that when the person taps on the screen the ViewFlipper goes to the next view. It works great but some of the text is too long so I went into my XML file and surrounded the textfield in one of my ViewFlipper views with a linearlayout and then a ScrollView. But now when I'm viewing the fields that are too long and show a scroll bar, I can't display the previous view. The onTouch method in my main activity isn't being executed. I have not been able to figure this out. I've read some posts about implementing or overriding the methods in ScrollView but I don't know where to do this in my activity. Does anyone know how I can program ScrollView to not intercept but keep its ability to scroll the view?
ScrollView myScroll;
myScroll.setOnTouchListener(new OnTouchListener){
#Override
public boolean onTouch(View v, MotionEvent touchevent) {
switch (touchevent.getAction()) {
case MotionEvent.ACTION_DOWN: {
oldTouchValue = touchevent.getX();
break;
}
case MotionEvent.ACTION_UP: {
float currentX = touchevent.getX();
if (oldTouchValue < currentX) {
//left swipe
return true;
}
if (oldTouchValue > currentX) {
//right swipe
return true;
}
return false;
}
}
I'm a newbie. I can't figure out how and where to call ResignFirstResponder to get rid of the keyboard when the user finished entering the text in an UITextField. I'm a bit confused by the UIResponder class. Mono documentation says: "To dismiss the keyboard, send the UIResponder.ResignFirstResponder message to the text field that is currently the first responder." How to do so? Can someone post a simple working example? There are many examples in Obj-C but none in C#. Many thanks.
Here's an example I've done recently:
private UITextField _textField;
public override void ViewDidLoad()
{
_textField = new UITextField();
_textField.Text = "King Alfonso III";
_textField.Bounds = bounds;
_textField.Placeholder = "Username";
_textField.ShouldReturn = delegate
{
_textField.ResignFirstResponder();
return true;
};
View.AddSubview(_textField);
}
Also if you are submitted a form with a button, make sure you resign all the textfields in the button click, to avoid getting responder errors.
public void ButtonClick(object sender, EventArgs e)
{
_textField.ResignFirstResponder();
// All other textboxes
// Other button logic
}