Reputation: 17
I've been scouring youtube for hours and I cant seem to find one that works. So far I have this in my code but it wont let me start a new activity.
public class MainActivity extends ActionBarActivity {
ArrayList<PerMoney> PeepList = new ArrayList<PerMoney>();
int pos = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListView people = (ListView)findViewById(R.id.peopleList);
setContentView(R.layout.activity_main);
if(PeepList.size() != 0)
UpdateList();
people.setOnItemClickListener(onListClick);
}
and then here is the onitemclick part
private AdapterView.OnClickListener onListClick=new AdapterView.OnItemClickListener()
{
ListView people = (ListView) findViewById(R.id.peopleList);
int res;
people.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
pos = position;
Intent intent = new Intent(this,SecondActivity.class);
startActivityForResult(intent, 0);
}
};
}
Upvotes: 1
Views: 132
Reputation: 5881
Shouldn't it be:
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
Upvotes: 1