我有结构:
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
if(getActivity() != null)
Intent intenta = StatisticsActivity.newInstance(this, (Question)mStream.get(position));
startActivity(intenta);
}
我有问题
(Intent intenta = StatisticsActivity.newInstance(this, (Question)mStream.get(position))):
The method newInstance(Activity, Question) in the type StatisticsActivity is not applicable for the arguments (UserQuestionsFragment, Question).
newInstance
:
public static Intent newInstance(Activity activity, Question question) {
Intent intent = new Intent(activity, StatisticsActivity.class);
intent.putExtra(QUESTION_KEY, question);
return intent;
}
Eclipse 提供了更改newInstance
:
public static Intent newInstance(UserQuestionsFragment userQuestionsFragment, Question question) {
Intent intent = new Intent(userQuestionsFragment, StatisticsActivity.class);
intent.putExtra(QUESTION_KEY, question);
return intent;
}
但它也会引发错误。什么是可能的?提前致谢