本文将分享无法附加到非ClientBehaviorHolder父级的详细内容,并且还将对无法附加到进程,已附加了一个调试器进行详尽解释,此外,我们还将为大家带来关于在ListViewItemTempl
本文将分享无法附加到非ClientBehaviorHolder父级的详细内容,并且还将对无法附加到进程,已附加了一个调试器进行详尽解释,此外,我们还将为大家带来关于
- 无法附加到非ClientBehaviorHolder父级(无法附加到进程,已附加了一个调试器)
在 ListView ItemTemplate 中不起作用 - Android BottomSheetBehavior RecyclerView 滑动冲突解决
- android studio:无法解析HttpClientBuilder
- android – BottomSheetBehavior有两个RecyclerView
无法附加到非ClientBehaviorHolder父级(无法附加到进程,已附加了一个调试器)
错误是
<p:ajax> Unable to attach <p:ajax> to non-ClientBehaviorHolder parent
这是xhtmlpagecode
<rich:panel> <f:facet name="header" > <h:outputText value="Tableau des articles" align="center"/> </f:facet> <h:form id="form"> <p:dataTable id="cars" var="car" value="#{articlesbean.LMatpilotaccess1}" editable="true" editMode="cell" widgetvar="carsTable"> <f:facet name="header"> Matériel du pilotage et accessoires </f:facet> <p:growl id="messages" showDetail="true"/> <p:contextMenu for="cars" widgetvar="cmenu"> <p:menuitem value="Edit Cell" icon="ui-icon-search" onclick="PF('carsTable').showCellEditor();return false;"/> <p:menuitem value="Hide Menu" icon="ui-icon-close" onclick="PF('cmenu').hide()"/> </p:contextMenu> <p:column headerText="Serie"> <p:ajax event="cellEdit" listenner="#{articlesbean.onCellEdit}" update=":form:messages" /> <p:cellEditor> <f:facet name="output"><h:outputText value="#{car.serie}" /></f:facet> <f:facet name="input"><p:inputText id="modelInput" value="#{car.serie}"/></f:facet> </p:cellEditor> </p:column> </p:dataTable> </h:form> </rich:panel>
这是我的豆子
@ManagedBean(name="articlesbean") @ViewScoped public class ArticlesBean implements Serializable{ @Inject private ArticlesDAO articleDAO; @Inject private Matpilotaccess1 matpilotaccess1; @Inject private Matpilotaccess2 matpilotaccess2; @Inject private Poteaux poteaux ; @Inject private Travgc1 travgc1; @Inject private Travgc2 travgc2; @Inject private Travresurbain travresurbain; private List LMatpilotaccess1 = new ArrayList(); private List LMatpilotaccess2 = new ArrayList(); private List LPoteaux = new ArrayList(); private List LTravgc1 = new ArrayList(); private List LTravgc2 = new ArrayList(); private List LTravresurbain = new ArrayList(); public void onCellEdit(CellEditEvent event) { Object oldValue = event.getoldValue(); Object newValue = event.getNewValue(); if(newValue != null && !newValue.equals(oldValue)) { FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO,"Cell Changed","Old: " + oldValue + ",New:" + newValue); FacesContext.getCurrentInstance().addMessage(null,msg); } } //// Getters and setters
ClientBehaviorHolder
interface的组件中.但是,Column
component class后面的< p:column>没有实现它.
DataTable
component class落后< p:dataTable>实现它.
你应该嵌套< p:ajax>在< p:dataTable>内代替:
<p:dataTable ...> <p:ajax ... /> <p:column ...> ... </p:column> </p:dataTable>
Exactly as demonstrated on their showcase site.换句话说,你的陈述
althought i copied the same example shown in showcase
其实不是真的.
在 ListView ItemTemplate 中不起作用
我开始工作了!答案在命令绑定中,如下所示:
<Entry.Behaviors>
<xct:EventToCommandBehavior
x:DataType="viewModel:EquationLibViewModel"
EventName="Completed"
Command="{Binding Path=BindingContext.EquationSetNameCompletedCommand,Source={Reference myEqLibPage}}"
CommandParameter="{Reference myEqLibPage}"/>
</Entry.Behaviors>
Android BottomSheetBehavior RecyclerView 滑动冲突解决
RecyclerView 在一个设置 BottomSheetBehavior 的 LinearLayout 中,BottomSheet 弹起时 RecyclerView 无法滑动,通过重写 Touch 监听由 RV 的不同状态进行事件消费处理滑动冲突
recyclerView.apply {
val linearLayoutManager = LinearLayoutManager(requireContext())
layoutManager = linearLayoutManager
adapter = rvAdapter
var touched = false
setOnTouchListener(View.OnTouchListener { v, event ->
if(linearLayoutManager.findFirstCompletelyVisibleItemPosition()==0 && touched){
//RV到顶部item完全显示时将滑动交给父控件
v.parent.requestDisallowInterceptTouchEvent(false)
touched = false
return@OnTouchListener true
}
when (event.action) {
MotionEvent.ACTION_DOWN -> {
//不允许父控件拦截触摸事件
v.parent.requestDisallowInterceptTouchEvent(true)
}
MotionEvent.ACTION_UP -> {
//允许父控件拦截触摸事件
v.parent.requestDisallowInterceptTouchEvent(false)
touched = true
}
}
v.performClick()
v.onTouchEvent(event)
true
})
}
android studio:无法解析HttpClientBuilder
我正在使用apache库来进行一些http请求,我需要更改
org.apache.http.impl.client.DefaultHttpClient;
不赞成使用
org.apache.http.impl.client.HttpClientBuilder;
但android工作室没有找到那个包.
我能怎么做?
解决方法
compile group: 'org.apache.httpcomponents',name: 'httpclient-android',version: '4.3.5'
android – BottomSheetBehavior有两个RecyclerView
我在LinearLayout中有一个带有BottomSheetBehavior的两个RecyclerView.当您单击第一个RecyclerView内的项目(带网格)时,RecyclerView将设置为Gone,并显示第二个RecyclerView(带有列表).当显示第二个Recycler时,您无法上下滑动BottomSheet而不是List即使在Expanded State中也在滚动.如果First Recycler已经上市,一切都很好.有没有办法让BottomSheet再次上下滑动?
<LinearLayout
android:id="@+id/sliding_layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="400dp"
app:layout_behavior="@string/bottomSheetBehavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:background="@color/white"
android:clickable="true"
android:scrollbars="none" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:background="@color/white"
android:clickable="true"
android:scrollbars="none" />
</LinearLayout>
GridAdapter:
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
String categorieName = mCategories.get(position);
final CategoryFilterEvent event = new CategoryFilterEvent(categorieName);
holder.grid_item_label.setText(categorieName);
holder.itemView.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EventBus.getDefault().post(event);
}
});
}
主要活动:
@Override
public void onCreate(Bundle savedInstanceState) {
linearlayoutmanager = new linearlayoutmanager(this);
listadapter = new listadapter(this, mList);
recyList.setAdapter(listadapter);
recyList.setLayoutManager(linearlayoutmanager);
gridLayoutManager = new GridLayoutManager(this, 3);
gridAdapter = new GridAdapter(this, new ArrayList<String>());
recyGrid.setAdapter(gridAdapter);
recyGrid.setLayoutManager(gridLayoutManager);
}
public void onEventMainThread(CategoryFilterEvent event) {
recyGrid.setVisibilty(GONE);
recyList.setVisiblity(VISIBLE);
}
解决方法:
BottomSheetBehavior的实现不支持内部的两个可滚动视图,这就是为什么这种布局永远不会“开箱即用”的原因.但是,这个问题有一个hacky但很简单的解决方法.首先,我们必须通过将该类的代码复制到我们的新CustomBottomSheetBehavior类来自定义BottomSheetBehavior.然后,通过替换行来修改“onLayoutChild”方法
mnestedScrollingChildRef = new WeakReference<>(findScrollingChild(child));
同
if (mnestedScrollingChildRef == null) {
mnestedScrollingChildRef = new WeakReference<>(findScrollingChild(child));
}
mnestedScrollingChildRef在BottomSheetBehavior类中具有包级访问权限,因此我们无法扩展它.
比,添加以下方法:
public void setnestedScrollingChildRef(View v) {
this.mnestedScrollingChildRef = new WeakReference<View>(v);
}
在您的Activity类中:
RecyclerView recyGrid = (RecyclerView)findViewById(R.id.grid);
RecyclerView recyList = (RecyclerView)findViewById(R.id.list);
layout = (LinearLayout)findViewById(R.id.sliding_layout_container);
recyGrid.addOnItemTouchListener(onItemTouchListener);
recyList.addOnItemTouchListener(onItemTouchListener);
onItemTouchListener代码:
RecyclerView.OnItemTouchListener onItemTouchListener = new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
setScrollable(layout, rv);
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestdisallowInterceptTouchEvent(boolean disallowIntercept) {
}
};
private void setScrollable(View bottomSheet, RecyclerView recyclerView){
ViewGroup.LayoutParams params = bottomSheet.getLayoutParams();
if (params instanceof CoordinatorLayout.LayoutParams) {
CoordinatorLayout.LayoutParams coordinatorLayoutParams = (CoordinatorLayout.LayoutParams) params;
CoordinatorLayout.Behavior behavior = coordinatorLayoutParams.getBehavior();
if (behavior != null && behavior instanceof CustomBottomSheetBehavior)
((CustomBottomSheetBehavior)behavior).setnestedScrollingChildRef(recyclerView);
}
}
我们在这里做的是捕获所有触摸事件,来到recyclerViews并将其作为mnestedScrollingChildRef添加到CustomBottomSheetBehavior类,以便可以正确的方式处理所有滚动事件.
更新于27.02.2018
在BottomSheetDialogFragment中使用这种方法涉及进一步的复制粘贴.我们应该创建CustomBottomSheetDialog,扩展AppCompatDialog并复制BottomSheetDialog类中的所有代码.然后将类变量mBehavior改为CustomBottomSheetBehavior,我在上面描述过.
然后,修改“wrapInBottomSheet”方法以在其中设置新行为:
ViewGroup.LayoutParams bottomSheetParams = bottomSheet.getLayoutParams();
if (bottomSheetParams instanceof CoordinatorLayout.LayoutParams) {
mBehavior = new CustomBottomSheetBehavior<>();
mBehavior.setBottomSheetCallback(mBottomSheetCallback);
mBehavior.setHideable(mCancelable);
mBehavior.setPeekHeight(*some value here*);
((CoordinatorLayout.LayoutParams) bottomSheetParams).setBehavior(mBehavior);
}
并在您的fragment类中重写“onCreateDialog”方法以使用CustomBottomSheetDialog:
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
CustomBottomSheetDialog dialog = new CustomBottomSheetDialog (getActivity(), R.style.YourDialogTheme);
dialog.setContentView(R.layout.bottom_sheet_page_fragment);
RecyclerView recyGrid = (RecyclerView)dialog.findViewById(R.id.grid);
RecyclerView recyList = (RecyclerView)dialog.findViewById(R.id.list);
layout = (LinearLayout)dialog.findViewById(R.id.sliding_layout_container);
recyGrid.addOnItemTouchListener(onItemTouchListener);
recyList.addOnItemTouchListener(onItemTouchListener);
return dialog;
}
其余代码保持不变.
关于无法附加到非ClientBehaviorHolder父级和无法附加到进程,已附加了一个调试器的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于
本文标签: