我在RecyclerView中使用PagerSnapHelper.RecyclerView中的第一个项目位于屏幕左侧位置.我需要中心对齐的第一个项目.
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
PagerSnapHelper snapHelper = new PagerSnapHelper();
binding.recyclerView.setOnFlingListener(null);
snapHelper.attachToRecyclerView(binding.recyclerView);
binding.recyclerView.setLayoutManager(layoutManager);
binding.recyclerView.setHasFixedSize(true);
binding.recyclerView.setItemAnimator(new DefaultItemAnimator());
binding.recyclerView.setAdapter(mAdapter);
Run Code Online (Sandbox Code Playgroud)
我有一个视图,需要通过动画将宽度从 100 更改为 200。
UIView.animate(withDuration: 5
,animations: {
self.backgroundPlaceHolderView.frame.size.width += 200
})
Run Code Online (Sandbox Code Playgroud)
我使用此代码为Logandroid类添加扩展名
fun Log.i2(msg:String):Unit{
Log.i("Test",msg)
}
Run Code Online (Sandbox Code Playgroud)
在活动中使用时
class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Log.i2("activity_main")
}
}
Run Code Online (Sandbox Code Playgroud)
找不到Log.i2。怎么了?
我有改造接口
interface ApiInterface {
@GET
Observable<okhttp3.ResponseBody> get(@Url String url,
@HeaderMap Map<String, Object> headerMap,
@QueryMap HashMap<String, String> queryMap );
}
Run Code Online (Sandbox Code Playgroud)
我这样调用,它完美地工作
HashMap<String, String> map = new HashMap<String, String>();
map.put("id","xyz");
apiInterface.get(url, getHeader(),map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
Run Code Online (Sandbox Code Playgroud)
但是当我通过时null,它不起作用
return apiInterface.get(url, getHeader(),null)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
Run Code Online (Sandbox Code Playgroud)
如何通过 null 来改造接口?
我可以在视图持有者中使用 notifyDataSetChanged() 吗?
class ItemViewHolder(context: Context?, view: View) : RecyclerView.ViewHolder(view) {
func update(){
// ...
// i need to update adapter for example
adapter.notifyDataSetChanged()
}
}
Run Code Online (Sandbox Code Playgroud) 我的类从BottomSheetDialogFragment 扩展,在这个布局中使用2 个recyclerViews。但总是 1 recyclerView 可滚动而其他 recyclerView 不起作用。
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/mainBottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewOne"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewTwo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) 我使用改造和我的界面如下
\n\n @GET("{link}")\n fun search(@Path(value = "link", encoded = true) link: String?): Call<Any>\nRun Code Online (Sandbox Code Playgroud)\n\n我是否需要对除字符“?\”之外的所有链接使用编码。
\n\n例子:
\n\n链接-> /api/search?&query=\xd8\xaa\xd8\xb3\xd8\xaa
\n\n通过改造编码链接 -> api/search%3F&query=%D8%AA%D8%B3%D8%AA
\n\n我需要这个链接-> api/search?&query=%D8%AA%D8%B3%D8%AA
\n\n我不需要将字符\'?\'转换为%3F。\ndo 是什么呢?
\n顶级功能和扩展中的哪一个在项目中到处都有功能?
顶级函数的 ñ
package com.test
fun A(){
}
Run Code Online (Sandbox Code Playgroud)
任何扩展
package com.test
fun Any.A(){
}
Run Code Online (Sandbox Code Playgroud)