淘宝搜
1.搜索页面
public class messageFragmentFragment extends BaseFragment<MessageFragmentPresenter> implements MessageFragmentContract.View {
@BindView(R.id.edit_guanjianzi)
EditText editGuanjianzi;
@BindView(R.id.btn_sousuo)
Button btnSousuo;
@BindView(R.id.rece_shoplie)
RecyclerView receShoplie;
Unbinder unbinder;
public static MessageFragmentFragment newinstance() {
MessageFragmentFragment fragment = new MessageFragmentFragment();
return fragment;
}
@Override
public void setupFragmentcomponent(@NonNull APPComponent appComponent) {
DaggerMessageFragmentComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.messageFragmentModule(new MessageFragmentModule(this))
.build()
.inject(this);
}
@Override
public View initView(@NonNull layoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_message, container, false);
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
//mPresenter.getmessage();
}
@Override
public void setData(@Nullable Object data) {
}
@Override
public void showLoading() {
}
@Override
public void hideLoading() {
}
@Override
public void showMessage(@NonNull String message) {
checknotnull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO: inflate a fragment view
View rootView = super.onCreateView(inflater, container, savedInstanceState);
unbinder = ButterKnife.bind(this, rootView);
return rootView;
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@OnClick(R.id.btn_sousuo)
public void onViewClicked() {
String s = editGuanjianzi.getText().toString().trim();
mPresenter.getmessage(s);
}
@Override
public void showDatafxian(NewsMessage newsMessage) {
List<NewsMessage.DataBean> data = newsMessage.getData();
//toast.maketext(getActivity(), "data:" + data, Toast.LENGTH_SHORT).show();
LinearLayoutManager manager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
receShoplie.setLayoutManager(manager);
MyMessageAdapter myMessageAdapter = new MyMessageAdapter(getActivity(), data);
receShoplie.setAdapter(myMessageAdapter);
}
}
2.搜索布局
<LinearLayout 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"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="请输入关键字"
android:id="@+id/edit_guanjianzi"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="搜索"
android:id="@+id/btn_sousuo"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:id="@+id/rece_shoplie"
/>
</LinearLayout>
3.搜索适配器
public class MyMessageAdapter extends RecyclerView.Adapter<MyMessageAdapter.MessageViewHolder> {
private context context;
private List<NewsMessage.DataBean> list;
public MyMessageAdapter(Context context, List<NewsMessage.DataBean> list) {
this.context = context;
this.list = list;
}
@NonNull
@Override
public MessageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View inflate = LayoutInflater.from(context).inflate(R.layout.message_layout, null);
MessageViewHolder messageViewHolder = new MessageViewHolder(inflate);
return messageViewHolder;
}
@Override
public void onBindViewHolder(@NonNull MessageViewHolder holder, int position) {
holder.text_name.setText(list.get(position).gettitle());
String[] splitImages = list.get(position).getImages().split("\\|");
Uri parse = Uri.parse(splitImages[0]);
holder.simp_ss.setImageURI(parse);
holder.text_price.setText(list.get(position).getPrice()+"");
}
@Override
public int getItemCount() {
return list.size();
}
class MessageViewHolder extends RecyclerView.ViewHolder
{
private final SimpleDraweeView simp_ss;
private final TextView text_price;
private final TextView text_name;
public MessageViewHolder(View itemView) {
super(itemView);
simp_ss = (SimpleDraweeView)itemView.findViewById(R.id.simp_ss);
text_name = (TextView)itemView.findViewById(R.id.text_name);
text_price = (TextView)itemView.findViewById(R.id.text_price);
}
}
}
4.搜索适配器布局
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="90dp"
android:layout_height="90dp"
app:placeholderImage="@mipmap/ic_launcher"
android:id="@+id/simp_ss"
android:layout_margin="@dimen/dp_10"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textSize="20sp"
android:layout_toRightOf="@id/simp_ss"
android:id="@+id/text_name"
android:layout_margintop="@dimen/dp_10"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="price"
android:textSize="20sp"
android:layout_toRightOf="@id/simp_ss"
android:id="@+id/text_price"
android:textcolor="#f00"
android:layout_marginTop="70dp"
/>
</RelativeLayout>
5.搜索接口
//发现详情页面
@GET("product/searchProducts?")
Observable<NewsMessage> getMessage(@Query("keywords") String keywords);
文章最后发布于: 2018-10-04 12:57:17
相关阅读
点击打开问题链接问题:给出一个R行C列的二维数组表, 求出这个表中的最长递增序列的长度,只能上下左右相邻。Sample Input5 5 1 2 3 4
11.8号,疗伤系电影《失恋33天》上映,小编看了片花,觉得不错,第一时间去捧场,笑道到肚子痛,碰上11.11淘宝,这个电影里面的一些道具也开始
淘宝不能发顺丰怎么回事?淘宝还能发顺丰快递吗?从6月1日顺丰突然宣布关闭对菜鸟的数据接口开始,在淘宝混的小伙伴肯定已经发现,淘宝
现在的信息在一旦在网络上出现,日后想要搜索基本上都是可以搜索到的。若是不想做一个透明人,或是不想让更多的人知道自己的详细信息
对于很多淘宝卖家,尤其是淘宝新手卖家而言,刷单是一件无法逾越的问题,因为如果不刷单,恐怕很难在现在竞争激烈的淘宝环境下拥有立锥之