I am using navigation drawer which moves from fragment to another when on clicked on the menu_item in it. In one of my fragments i have a listview. I have to move to another ACTIVITY and not FRAGMENT when clicked on one of the list view item here is the code of both the things the Activity as well as fragment. I have used intent but still it gives error on the parameters of intent.
"One" Fragment package com.navigate2;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
/**
* A simple {@link Fragment} subclass.
*/
public class One extends Fragment {
public One() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_one, container, false);
ListView listView = (ListView)listView.findViewById(R.id.mobile_list2);
listView.setBackgroundColor(Color.WHITE);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position)
{
case 0:
Intent intent = new Intent(One.this,AndroidClass.class);
startActivity(intent);
}
}
});
}
}
"AndroidClass" Activity
package com.navigate2;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AppCompatActivity;
/**
* Created by Nathani Aliakbar on 06-01-2016.
*/
public class AndroidClass extends AppCompatActivity
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.textview);
}
}