我有一个包含 3 个项目的列表视图,我想根据被单击的项目移动到一个新的活动,即每个项目在单击时应该移动到不同的活动。我已经尝试了针对类似问题的解决方案,但我仍然不知道如何让它去另一个活动
package com.example.wizer;
import java.util.ArrayList;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Options extends Activity implements OnItemClickListener {
WifiManager wifi;
BroadcastReceiver receiver;
IntentFilter filter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_options);
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
filter = new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
registerReceiver(rcver, filter);
ListView list = (ListView) findViewById(R.id.l1);
ArrayList < String > List = new ArrayList < String > ();
List.add("List available networks .");
List.add("List APs .");
List.add("List Networks according to thier signal strength .");
ArrayAdapter < String > adp = new ArrayAdapter < String > (this, android.R.layout.simple_list_item_1, List);
list.setAdapter(adp);
wifi.startScan();
}
// On create
final BroadcastReceiver rcver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
};
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_options, menu);
return true;
}
public void onItemClick(AdapterView <? > arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
if (arg3 == 0) {
Intent NL = new Intent(Options.this, Networks.class);
startActivity(NL);
} else if (arg3 == 1) {
Intent NL = new Intent(Options.this, AP.class);
startActivity(NL);
} else if (arg3 == 2) {
Intent NL = new Intent(Options.this, Signal.class);
startActivity(NL);
}
}
}