【发布时间】:2015-07-15 01:14:31
【问题描述】:
我有一个片段
public class TwitterFragment extends Fragment implements OnClickListener {}
从这个片段中,我调用了一个意图:
Intent intent = new Intent(this, WebViewActivity.class);
在哪里,
public class WebViewActivity extends Activity {
但是调用意图给出错误:
Error:(214, 33) error: no suitable constructor found for Intent(TwitterFragment,Class<WebViewActivity>)
constructor Intent.Intent(String,Uri) is not applicable
(argument mismatch; TwitterFragment cannot be converted to String)
constructor Intent.Intent(Context,Class<?>) is not applicable
(argument mismatch; TwitterFragment cannot be converted to Context)
当 TwitterFragment 类扩展 Activity 而不是片段时,此代码有效。
【问题讨论】:
标签: java android android-fragments android-intent