私は構造を持っています:
@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;
}
ただし、エラーも発生します。何が可能ですか?前もって感謝します