android,,,,,Intent 传值问题。(android studio)
MainActivity:listview.setOnItemClickListener(newAdapterView.OnItemClickListener(){@Ov...
MainActivity:
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent();
intent.putExtra("key",position);
intent.setClass(MainActivity.this, NewsActivity.class);
startActivity(intent3);
NewsActivity:
Intent intent = getIntent();
int i = intent.getIntExtra("key",position);
问题:position传不过来(红字,cannot resolve symbol 'position')。没有分了,还是希望大神能帮我解决一下,好人一生平安!!!
这是我manifest:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NewsActivity">
</activity> 展开
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent();
intent.putExtra("key",position);
intent.setClass(MainActivity.this, NewsActivity.class);
startActivity(intent3);
NewsActivity:
Intent intent = getIntent();
int i = intent.getIntExtra("key",position);
问题:position传不过来(红字,cannot resolve symbol 'position')。没有分了,还是希望大神能帮我解决一下,好人一生平安!!!
这是我manifest:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NewsActivity">
</activity> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询