无法重定向到android中的另一个意图

时间:2013-05-21 22:44:16

标签: java android android-intent

我在点击一个列表项时尝试转移到另一个意图。在下面的示例中,我需要在单击“属性”列表后立即转到另一个意图MatchingInterest

但无论如何,每当我点击属性列表时,它都不会将我重定向到MatchingInterest page。知道为什么会这样吗?

public class MenuFragment extends ListFragment {

    private String user_id = "1234";

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1, new String[] { " Settings", " Attributes"}));
        getListView().setCacheColorHint(0);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {

        //get selected items
        String selectedValue = (String) getListAdapter().getItem(position);

        if(selectedValue.equals("Attributes")) {
            Bundle bundle = new Bundle();
            bundle.putString("USERID", user_id);
            Intent thesisProject = new Intent(getActivity(), MatchingInterest.class);
            thesisProject.putExtras(bundle);

            startActivity(thesisProject);
        }
    }
}

1 个答案:

答案 0 :(得分:2)

new String[] { " Settings", " Attributes"}

你们两个都有空间。

'属性'不等于'属性'