Comments (16)
If you can provide a screenshot of the row item on the mobile device, that would be great.
—
Sent from Mailbox
On Fri, Jan 23, 2015 at 8:13 PM, DivineCake [email protected]
wrote:
Hi, I'm having some problems when using DocumentView in a row item, it makes the whole row item not clickable. I fixed this by android:descendantFocusability="blocksDescendants" on the RelativeLayout. The problem however is that selecting the DocumentView does not select the Row Item, unlike using a normal TextView does. Clicking outside the DocumentView does indeed trigger the Row Item. What I want to achieve is that clicking the DocumentView, selects the Row Item similar to how it works when I use a normal TextView. Is this an ongoing issue or I'm doing something wrong?
I'll be attaching my layout if that helps.
Reply to this email directly or view it on GitHub:
#59
from textjustify-android.
With DocumentView, tapping on it doesn't select the ListItem
With TextView, tapping on it select the ListItem
The red dot indicates tap location.
Thanks! Awesome library btw.
from textjustify-android.
I will look at it when I get home. But I think it's because TextView extends View while DocumentView extends Scrollview. So this means that the touch events might not be propagating into the parent views. And I side note, I recommend you use the SqueezeHyphentor to condense the text.
—
Sent from Mailbox
On Fri, Jan 23, 2015 at 9:30 PM, DivineCake [email protected]
wrote:
With DocumentView, tapping on it doesn't select the ListItem
With TextView, tapping on it select the ListItem
The red dot indicates tap location.Thanks! Awesome library btw.
Reply to this email directly or view it on GitHub:
#59 (comment)
from textjustify-android.
Hi Mathew Kurian,
I am able to "hack" fix it, thanks to your suggestion that it extends ScrollView. Solved it by adding an onTouchListener on the DocumentView which calls super() to the parent view, referring to the List. After which calling ListItem.performItemClick does the job.
description.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
View view = (View) v.getParent().getParent();
ListView list = (ListView) view.findViewById(R.id.list);
list.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
break;
}
return true;
}
});
The only problem now, albeit minor, is that using performItemClick doesn't seem to change the state of the ListRow, thereby the row is not getting highlighted.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/list_row_bg" android:state_pressed="false" android:state_selected="false" />
<item android:drawable="@drawable/list_row_bg_hover" android:state_pressed="true" />
<item android:drawable="@drawable/list_row_bg_hover" android:state_pressed="false" android:state_selected="true" />
</selector>
from textjustify-android.
@divineCake I am glad you found a solution. To make the click work, i would suggest extending document view and following the suggestion at StackOverflow. I have not tried this, but it does look promising.
from textjustify-android.
Opening until release
from textjustify-android.
description.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
View view = (View) v.getParent().getParent();
ListView list = (ListView) view.findViewById(R.id.list);
list.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
break;
}
return true;
}
});
Would just like to note that this doesn't work as intended, position in this context is limited to the adapter's position index and not to the ListView -> Item's index. Tried your suggestion, though I have no luck with it.
from textjustify-android.
Can you give me a sample code I can run on my system to recreate the issue
—
Sent from Mailbox
On Sun, Jan 25, 2015 at 9:43 PM, DivineCake [email protected]
wrote:
description.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_UP: View view = (View) v.getParent().getParent(); ListView list = (ListView) view.findViewById(R.id.list); list.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position)); break; } return true; } });Would just like to note that this doesn't work as intended, position in this context is limited to the adapter's position index and not to the ListView -> Item's index. Tried your suggestion, though I have no luck with it.
Reply to this email directly or view it on GitHub:
#59 (comment)
from textjustify-android.
The way I structured my list is as follows:
listView.setAdapter(adapter);
listView.setOnItemClickListener(){
}
Now given that the DocumentView is inside the adapter, the onTouchListener for the DocumentView is inside the same adapter class.
Adapter class
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
description.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
ListView list = (ListView) parent;
listView.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position));
break;
}
return true;
}
});
}
position in this context however is limited to the index 0-4 (in my case which resets to 0 again when I scroll down the list), and not to the ListView's index. There seems to be no way of accessing the selected index of ListView other than on the ListView itself
from textjustify-android.
Can u provide the xml as a file please?
—
Sent from Mailbox
On Sun, Jan 25, 2015 at 9:57 PM, DivineCake [email protected]
wrote:
The way I structured my list is as follows:
listView.setAdapter(adapter); listView.setOnItemClickListener(){ }Now given that the DocumentView is inside the adapter, the onTouchListener for the DocumentView is inside the same adapter class.
Adapter class@Override public View getView(final int position, View convertView, final ViewGroup parent) { description.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_UP: ListView list = (ListView) parent; listView.performItemClick(list.getChildAt(position), position, list.getItemIdAtPosition(position)); break; } return true; } }); }position in this context however is limited to the index 0-4 (in my case which resets to 0 again when I scroll down the list), and not to the ListView's index. There seems to be no way of accessing the selected index of ListView other than on the ListView itself
Reply to this email directly or view it on GitHub:
#59 (comment)
from textjustify-android.
Ok. I have updated the library to support what you want. Use version 2.0.8-SNAPSHOT
to get the latest code. This supports features you are looking for. Refer to ListViewTest to see the sample code. The xml files and the PressableDocumentView
are all in the sample project.
EDITED: PressableDocumentView
introduced into the sample. It is a simple extension of DocumentView
.
from textjustify-android.
Sorry, I just got home and was planning to make a sample simple program to demonstrate. But I guess you beat me to it! Thanks will look into it! Thank you so much, I appreciate all the work you've done on this awesome library.
from textjustify-android.
Hi, how do I update to 2.0.8-SNAPSHOT? I have done a Gradle clean and build but it don't seem to have updated the library to have PressableDocumentView. I tried recreating myself a similar class but I get Error:(44) No resource identifier found for attribute 'documentView_disallowInterceptTouch' in package 'com.sample' following your same code. Sorry, I'm new to GitHub.
from textjustify-android.
Use version 2.0.8
from textjustify-android.
Thank you very much! Was able to make it work now! I do appreciate all your support.
from textjustify-android.
Np
from textjustify-android.
Related Issues (20)
- How to set RTL for Arabic Text
- Extra space in AlertDialog
- max line limit HOT 1
- com.bluejamesbond.text.StringDocumentLayout$PlainDocumentException: Cannot fit word(s) into one line. Font size too large? HOT 2
- is Html text Support ?
- bug java.lang.IllegalArgumentException:
- How to change the text size? HOT 3
- java.lang.IndexOutOfBoundsException HOT 2
- Crash on Android 7.X
- DocumentViews in LinearLayout and EventListeners
- Background Color does not change with Spannables, please help.
- DocumentView has a problem with ExpandableListView
- RTL supprot for documentView_textFormat="plain"
- Broken on API 21 when change portrait to landscape positions
- Hyphenate license
- Image Span test does not work
- Report crash .onMeasure
- How to use android:ellipsize="end" attributes????
- bug: java.lang.IllegalArgumentException: width and height must be > 0
- onClick in Clickablespan is not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textjustify-android.