Closed polcham closed 9 years ago
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 notifications@github.com 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: https://github.com/bluejamesbond/TextJustify-Android/issues/59
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.
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 notifications@github.com 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: https://github.com/bluejamesbond/TextJustify-Android/issues/59#issuecomment-71298448
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>
@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.
Opening until release
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.
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 notifications@github.com 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: https://github.com/bluejamesbond/TextJustify-Android/issues/59#issuecomment-71411556
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
Can u provide the xml as a file please?
— Sent from Mailbox
On Sun, Jan 25, 2015 at 9:57 PM, DivineCake notifications@github.com 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: https://github.com/bluejamesbond/TextJustify-Android/issues/59#issuecomment-71412227
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
.
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.
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.
Use version 2.0.8
Thank you very much! Was able to make it work now! I do appreciate all your support.
Np
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.