gpt4 book ai didi

android - ListView 不在 AndroidSlidingUpPanel 中滚动

转载 作者:太空狗 更新时间:2023-10-29 15:38:32 25 4
gpt4 key购买 nike

<分区>

我小时候有一个带有 ListView 的 AndroidSlidingUpPanel。我的问题是当 Pane 展开并且我尝试滚动 ListView 时, Pane 被滚动了。我发现我必须覆盖 onInterceptTouchEvent 并将特定区域设置为 MotionEvent.ACTION_DOWN(或类似的东西),但我真的迷失了。

你能帮我告诉我怎么解决这个问题吗,我的代码是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
sothree:collapsedHeight="40dp"
sothree:dragView="@+id/name"
sothree:shadowHeight="1dp" >

<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >



</FrameLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eee"
android:clickable="true"
android:focusable="false" >

<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:text=""
android:textSize="14sp" />

<ListView
android:id="@+id/lv_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="40dp" />
</RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

和 MainActivity:

public class MainActivity extends Activity implements PanelSlideListener, OnItemClickListener {
public static final String SAVED_STATE_ACTION_BAR_HIDDEN = "saved_state_action_bar_hidden";

private ListView _menuListView;
private SlidingUpPanelLayout _slideUpPane;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.activity_main);

_slideUpPane = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

_slideUpPane.setShadowDrawable(getResources().getDrawable(R.drawable.above_shadow));
_slideUpPane.setAnchorPoint(0.2f);
_slideUpPane.setPanelSlideListener(this);

ArrayList<MenuItem> menuItems = new ArrayList<MenuItem>();
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));
menuItems.add(new MenuItem("Menu Item"));

_menuListView = (ListView) findViewById(R.id.lv_menu);
_menuListView.setAdapter(new MenuAdapter(this, menuItems));
_menuListView.setOnItemClickListener(this);


boolean actionBarHidden = savedInstanceState != null ?
savedInstanceState.getBoolean(SAVED_STATE_ACTION_BAR_HIDDEN, false): false;
if (actionBarHidden) {
getActionBar().hide();
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public void onPanelSlide(View panel, float slideOffset) {
Log.i(TAG, "onPanelSlide, offset " + slideOffset);
if (slideOffset < 0.2) {
if (getActionBar().isShowing()) {
getActionBar().hide();
}
} else {
if (!getActionBar().isShowing()) {
getActionBar().show();
}
}

}

@Override
public void onPanelCollapsed(View panel) {
Log.i(TAG, "onPanelCollaped");
}

@Override
public void onPanelExpanded(View panel) {
Log.i(TAG, "onPanelExpanded");
}

@Override
public void onPanelAnchored(View panel) {
Log.i(TAG, "onPanelAnchored");
}

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
_slideUpPane.collapsePane();
}

我尝试使用这些,但我不知道该怎么做: Android, SlidingPaneLayout and listView ListView in SlidingUpPanel is not scrollable

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com