一项活动中的两个意图

时间:2015-11-30 20:02:56

标签: android

问题是我从添加注释类发送一个意图然后从第三个活动返回一个带有值的意图并在addnote类中获取它但它崩溃时出现零点异常

public class AddNote extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_note);

        String vstr=getIntent().getExtras().getString("R");
        int v=Integer.parseInt(vstr);

        if (v == 0){
            EditText editText = (EditText) findViewById(R.id.editText);
            editText.setBackgroundColor(Color.BLACK);
        }
    }

    public void Option(View view) {
        Intent intent = new Intent(getApplicationContext(),list.class);
        startActivity(intent);
    }
}

public class Color_view extends AppCompatActivity
{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_color_view);

        ListView listView = (ListView) findViewById(R.id.lv);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position==0){

                    Intent intent = new Intent(getApplicationContext(),AddNote.class);
                    intent.putExtra("R", 0);
                    startActivity(intent);
                }
            }
        });
        movie_titles2 = getResources().getStringArray(R.array.movie_titles2);

        int i = 0 ;
        adaptor = new colorAdaptor(getApplicationContext(),R.layout.font_layout);
        listView.setAdapter(adaptor);
        for (String titles: movie_titles2){
            colorProvider listDataProvider2 = new colorProvider(movie_poster_resource[i],titles);
            adaptor.add(listDataProvider2);
            i++;
        }
    }
}

0 个答案:

没有答案