使用单击事件重定向到空白页面

时间:2015-09-23 00:21:04

标签: android gridview

我正在尝试将当前页面重定向到包含onItemClick事件的空白页面,但发生了错误。

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity_universiteler, container, false);
    GridView listView = (GridView) rootView.findViewById(R.id.gridView);
    ((GridView) listView).setAdapter(new ImageAdapter(this));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Uri link = Uri.parse(Site[position]);
            Intent tara = new Intent(Intent.ACTION_DEFAULT, link);
            startActivity(tara);
        }
    });
    return rootView;
}

1 个答案:

答案 0 :(得分:0)

主席摘要,因为没有定向到我希望null的页面被定向到没有任何错误的页面

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                View rootView = inflater.inflate(R.layout.activity_universiteler, container, false);
                GridView listView = (GridView) rootView.findViewById(R.id.gridView);
            ((GridView) listView).setAdapter(new ImageAdapter(this));
            listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Uri link = Uri.parse(Site[position]);
                    Intent tara = new Intent(Intent.ACTION_DEFAULT, link);
                    startActivity(tara);
                }
            });
            return rootView;
        }