Android 尝试从BaseAdapter启动Tactivity时出现未知错误
我在android上做自定义ListView,每个项目上都有一个共享按钮。点击按钮后,必须创建选择器(facebook等)。但当我点击它时,应用程序崩溃,logcat什么也没显示。请帮帮我Android 尝试从BaseAdapter启动Tactivity时出现未知错误,android,android-intent,baseadapter,custom-lists,start-activity,Android,Android Intent,Baseadapter,Custom Lists,Start Activity,我在android上做自定义ListView,每个项目上都有一个共享按钮。点击按钮后,必须创建选择器(facebook等)。但当我点击它时,应用程序崩溃,logcat什么也没显示。请帮帮我 这是我的适配器: public class AdapterQ extends BaseAdapter { List<Quotes> sss; Context ss; Intent sendIntent; public AdapterQ(Context ss, List<Quotes>i
这是我的适配器:
public class AdapterQ extends BaseAdapter {
List<Quotes> sss;
Context ss;
Intent sendIntent;
public AdapterQ(Context ss, List<Quotes>items){
this.ss = ss;
this.sss = items;
}
@Override
public int getCount() {
return sss.size();
}
@Override
public Object getItem(int position) {
return sss.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
ss.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.quoteitem, null);
}
ImageView imgIcon = (ImageView) convertView.findViewById(R.id.legendImage);
final TextView tvTitle = (TextView) convertView.findViewById(R.id.legendName);
ImageView ssss= (ImageView) convertView.findViewById(R.id.Nation);
final Quotes quotes = sss.get(position);
imgIcon.setImageResource(quotes.getIcon());
tvTitle.setText(quotes.getText());
ssss.setImageResource(R.mipmap.ic_share_black_24dp);
ssss.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendIntent =new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, tvTitle.getText());
sendIntent.setType("text/plain");
ss.startActivity(Intent.createChooser(sendIntent, "Поделиться..."));
}
});
return convertView;
}
}
片段:
public class AllFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rrrr = inflater.inflate(R.layout.fragment_all, container, false);
String[] ss = getResources().getStringArray(R.array.Абай);
String[] qq = getResources().getStringArray(R.array.Абылай);
String[] sr = new String[ss.length + qq.length];
System.arraycopy(ss, 0, sr, 0, ss.length);
System.arraycopy(qq, 0, sr, ss.length, qq.length);
ListView se = (ListView) rrrr.findViewById(R.id.listView2);
shuffleArray(sr);
List<Quotes> ser = new ArrayList<Quotes>();
for (int s = 0; s<sr.length; s++){
if(Arrays.asList(ss).contains(sr[s]) ){
Quotes quotes = new Quotes();
quotes.setText(sr[s]);
quotes.setIcon(R.drawable.abay);
ser.add(quotes);
} else if(Arrays.asList(qq).contains(sr[s])){
Quotes quotes = new Quotes();
quotes.setText(sr[s]);
quotes.setIcon(R.drawable.abylai);
ser.add(quotes);
}
}
AdapterQ ses = new AdapterQ(getActivity().getApplicationContext(), ser);
se.setAdapter(ses);
return rrrr;
}
public类AllFragment扩展了Fragment{
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
//为该碎片膨胀布局
视图rrrr=充气机。充气(R.layout.fragment\u all,容器,false);
字符串[]ss=getResources().getStringArray(R.array.Аааа);
字符串[]qq=getResources().getStringArray(R.array.Аббаа);
String[]sr=新字符串[ss.length+qq.length];
系统阵列副本(ss,0,sr,0,ss长度);
系统阵列副本(qq,0,sr,ss.length,qq.length);
ListView se=(ListView)rrrrr.findViewById(R.id.listView2);
沙弗雷(高级),;
List ser=new ArrayList();
对于(int s=0;s此处:
试试这个:
AdapterQ ses = new AdapterQ(getActivity(), ser);
你的代码中的ss是什么?ss是上下文。这是字母我检查了你的代码,工作正常,请发布活动的完整代码和适配器类编辑的代码如果你发现错误请告诉我我的日志显示0我可能必须添加一些东西到清单?
AdapterQ ses = new AdapterQ(getActivity().getApplicationContext(), ser);
AdapterQ ses = new AdapterQ(getActivity(), ser);