QuickReturn
QuickReturn copied to clipboard
Enable top and bottom quickreturn
Hi, is it possible to enable top and bottom quickreturnviews at same time for same listview?
Thank you.
Yeah, check the sample app here. You can call addTargetView
twice, one for top and one for bottom.
If you run the sample app, open the actionbar overflow menu and tap "Toggle bottom QuickReturn", then you'll have both active at the same time.
Thank you for your quick response. I asked you because i tried this already out and didnt get it work. The "bottom view" is placed over the "top view" but is scrolled down when the list is scrolled, so the place is wrong but the scrolling is right, both views are hidden. By the way using only topView works fine.
The differences to youre example are:
- I am adding the framelayout in onCreate to an other layout (relativelayout)
- I have separeted the Activity from the View (two different classes), the activity is acting as the presenter
- The "top" and "bottom" views are included in my activity_layout.xml per "include"
- I have to call adddTargetView in onGlobalLayout in my view, otherwise getWidth of the topView always returns 0 and topView (without bottomView) doesnt work, too
Do you have any ideas? Thank you.
I will check this and get back to you. If you can provide some code snippets or a test app demonstrating the bug, it would be super helpful. Thanks!
Hi Felipe, thank you for reopening...Here are some snippets, hope they will help you.. Can't figure out how it works in your test app.. Thank you for your help.
base_layout.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/base_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/base_view_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<ListView
android:id="@+id/base_drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFFFFF"
android:choiceMode="none"
android:divider="#E6E6E6"
android:dividerHeight="1dp" />
</android.support.v4.widget.DrawerLayout>
testlayout.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E6E6E6" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#FFFFFF"
android:dividerHeight="1dp"
android:padding="0dp" >
</ListView>
<LinearLayout
android:id="@+id/topView_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white" >
<include
android:id="@+id/topView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/topView_layout />
</LinearLayout>
<LinearLayout
android:id="@+id/bottomView_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#33b5e5" >
<include
android:id="@+id/bottomView"
layout="@layout/bottomView_layout"
android:visibility="gone" />
</LinearLayout>
</FrameLayout>
public class MyBaseActivity extends Activity {
@override
public onCreate(Bundle b){
super.onCreate(b);
setContentView(R.layout.my_base_layout);
IMyViewInterface viewInterface = createView();
..
this.baseContainer = (RelativeLayout)findViewById(R.id.base_view_container);
View view = ViewCreator.createView(getLayoutInflater(), this.baseContainer, this.view.getResource());
viewInterface.setView(view);
viewInterface.setup();
baseContainer.addView(view);
}
protected abstract IMyViewInterface createView();
}
public class MyTestActivity extends MyBaseActivity {
@override
protected IMyViewInterface createView() {
return new MyTestView();
}
public class MyTestView implements IMyViewInterface {
private View view;
@override
public void setView(View view) {
this.view = view;
}
@override
public void setup() {
this.bottomView = this.view.findViewById(R.id.bottomView);
this.bottomView.setVisibility(View.GONE);
this.TopView = this.view.findViewById(R.id.topView);
this.list = this.view.findViewById(R.id.list);
this.listOrders.setAdapter(new QuickReturnAdapter(this.adapter));
final QuickReturnAttacher quickReturnAttacher = QuickReturnAttacher.forView(list);
quickReturnAttacher.addTargetView(this.scanInfo, QuickReturnTargetView.POSITION_BOTTOM);
this.listOrders.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener()
{
@Override
public void onGlobalLayout()
{
//I have to do it this way because otherwise topView is never shown, because height is always 0 if called getHeight() directly in setup()
quickReturnAttacher.addTargetView(stopDescriptionContainer,
QuickReturnTargetView.POSITION_TOP, topView.getHeight())
.setAnimatedTransition(false);
}
});
}
Hi Felipe, any progress on this issue? did my code snippets help you?
@misrakli sorry didn't have time to check yet. Will keep you posted
Ok..