首页 > 代码库 > <错误>
<错误>
1.
package com.multak.cookaraclient.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.multak.cookaraclient.R;
import com.multak.cookaraclient.info.MusicInfo;
import java.util.List;
/**
* Created by guoxw on 2017/6/19.
*/
public class ProRecycleViewAdapter extends RecyclerView.Adapter<ProRecycleViewAdapter.ViewHolder> implements View.OnClickListener {
private static final String TAG = "ProRecycleViewAdapter";
/**
*
*/
private ProRecycleViewAdapter.OnItemClickListener mOnItemClickListener=null;
List<MusicInfo> data;
Context context;
int type;
/**
* 点击的条目
*/
int num=-2;
public void textSize(int type){
this.type=type;
}
public ProRecycleViewAdapter(List<MusicInfo> data, Context context) {
this.data = http://www.mamicode.com/data;""+x);
if(type==2){
holder.textView_SongName.setTextColor(context.getResources().getColor(R.color.colorHomeText));
holder.textView_SongSinger.setTextColor(context.getResources().getColor(R.color.colorHomeText));
}else if(type==1){
holder.textView_SongName.setTextColor(context.getResources().getColor(R.color.colorSingerName));
holder.textView_SongSinger.setTextColor(context.getResources().getColor(R.color.colorSingerName));
}
if(num==position){
Log.d(TAG, "onBindViewHolder: NUM: "+num);
Log.d(TAG, "onBindViewHolder: Position: "+position);
holder.textView_SongName.setTextColor(context.getResources().getColor(R.color.colorAccent));
}
/**
*
*/
holder.itemView.setTag(position);
}
@Override
public int getItemCount() {
return data.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
View viewItem;
TextView textView_no;
TextView textView_SongName,textView_SongSinger;
public ViewHolder(View itemView) {
super(itemView);
viewItem=itemView;
textView_SongName= (TextView) itemView.findViewById(R.id.textView_SongName);
textView_SongSinger= (TextView) itemView.findViewById(R.id.textView_SongSinger);
textView_no= (TextView) itemView.findViewById(R.id.textView_no);
}
}
/**
*
* @param
*/
public static interface OnItemClickListener{
void onItemClick(View view,int position);
}
/**
*
* @param v
*/
@Override
public void onClick(View v) {
if(mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(v,(int)v.getTag());
}
}
/**
*
* @param listener
*/
public void setOnItemClickListener(ProRecycleViewAdapter.OnItemClickListener listener) {
this.mOnItemClickListener=listener;
}
public void setItemClickColor(int num){
this.num=num;
}
}
2.
package com.multak.cookaraclient.fragment;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.multak.cookaraclient.R;
import com.multak.cookaraclient.adapter.ProRecycleViewAdapter;
import com.multak.cookaraclient.info.MusicInfo;
import com.multak.cookaraclient.info.ToastUtils;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
*/
public class ProFragment extends Fragment {
private static final String TAG = "ProFragment";
View view;
RecyclerView recyclerView;
ProRecycleViewAdapter proRecycleAdapter;
List<MusicInfo>data=http://www.mamicode.com/new ArrayList<>();""+position);
Log.d(TAG, "onBindViewHolder: TOAST: "+position);
proRecycleAdapter.setItemClickColor(position);
proRecycleAdapter.notifyDataSetChanged();
}
});
return view;
}
public void addMusicInfo(){
data.add(new MusicInfo("我知道","阎韦伶"));
data.add(new MusicInfo("千里之外","周杰伦"));
data.add(new MusicInfo("同桌的你","老狼"));
data.add(new MusicInfo("我知道","阎韦伶"));
data.add(new MusicInfo("千里之外","周杰伦"));
data.add(new MusicInfo("同桌的你","老狼"));
data.add(new MusicInfo("我知道","阎韦伶"));
data.add(new MusicInfo("千里之外","周杰伦"));
data.add(new MusicInfo("同桌的你","老狼"));
data.add(new MusicInfo("我知道","阎韦伶"));
data.add(new MusicInfo("千里之外","周杰伦"));
data.add(new MusicInfo("同桌的你","老狼"));
data.add(new MusicInfo("我知道","阎韦伶"));
data.add(new MusicInfo("千里之外","周杰伦"));
data.add(new MusicInfo("同桌的你","老狼"));
data.add(new MusicInfo("我知道","阎韦伶"));
data.add(new MusicInfo("千里之外","周杰伦"));
data.add(new MusicInfo("同桌的你","老狼"));
}
public void selectOperate(final int posi,View view){
View contentView = LayoutInflater.from(getActivity()).inflate(R.layout.popup_song, null);
final PopupWindow popupWindow = new PopupWindow(contentView,600, LinearLayout.LayoutParams.WRAP_CONTENT, true);
WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
TextView textView_xiai= (TextView) contentView.findViewById(R.id.textView_xiai);
TextView textView_yuyue= (TextView) contentView.findViewById(R.id.textView_yuyue);
TextView textView_zhiding= (TextView) contentView.findViewById(R.id.textView_zhiding);
TextView textView_bofang= (TextView) contentView.findViewById(R.id.textView_bofang);
textView_xiai.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtils.showtoast(getActivity(),"喜爱操作");
popupWindow.dismiss();
}
});
textView_yuyue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtils.showtoast(getActivity(),"预约操作");
popupWindow.dismiss();
}
});
textView_zhiding.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtils.showtoast(getActivity(),"置顶操作");
popupWindow.dismiss();
}
});
textView_bofang.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtils.showtoast(getActivity(),"播放操作");
popupWindow.dismiss();
}
});
int popupWidth = view.getMeasuredWidth();
int popupHeight = view.getMeasuredHeight();
int[] location = new int[2];
view.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
Log.d(TAG, "selectOperate: 坐标:"+x+"&&"+y);
popupWindow.setTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true);
popupWindow.showAtLocation(view, Gravity.TOP|Gravity.LEFT, x+200, y+140);
popupWindow.showAsDropDown(view);
view.setAlpha(1f);
}
}
3.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="80dp"> <TextView android:layout_width="50dp" android:layout_height="50dp" android:textSize="@dimen/songnumbersize" android:gravity="center" android:textColor="@color/colorSingerName" android:id="@+id/textView_no"/> <LinearLayout android:layout_marginLeft="@dimen/imagemagintext" android:layout_height="50dp" android:layout_width="0dp" android:layout_weight="1" android:orientation="vertical"> <TextView android:id="@+id/textView_SongName" android:layout_width="match_parent" android:layout_height="30dp" android:paddingTop="5dp" android:gravity="center_vertical" android:textColor="@color/colorSongName" android:textSize="@dimen/songnamesize"/> <TextView android:id="@+id/textView_SongSinger" android:layout_width="match_parent" android:layout_height="20dp" android:gravity="center_vertical" android:textColor="@color/colorSongName" android:textSize="@dimen/songsingersize"/> </LinearLayout> </LinearLayout>
<错误>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。