好的,我从用户输入的一些数据中创建了一个简单的字符串。我现在希望将此数据作为字符串(类似 CSV 的字符串)传递到下一个活动。在一个例子中,我看到了这一点:
intent.putExtra(EXTRA_MESSAGE, string_to_be_sent)
Run Code Online (Sandbox Code Playgroud)
但这会引发错误,指出 EXTRA_MESSAGE 不是值 - 即。它被意图识别。我认为这个例子已经过时了。我应该使用什么来发送字符串?我查看了文档并发现了这一点:
public Intent putExtra (String name, String value)
Run Code Online (Sandbox Code Playgroud)
但是我的值的名称是什么?我选择的任何东西,还是必须是包名?谢谢您的帮助 :)
我想知道的是,是否可以打开Java类,比如FileWriter,直到查看它们内部的代码.
谢谢您的帮助!
我创建了一个arraylist和一个ListView.我打算遍历ListView,检查它们是否被检查,然后将对象(使用ListView.getItem())添加到我的arraylist.但是我得到一个NullPointerException.ArrayList people_selected,在类顶部声明如下:
ArrayList<PeopleDetails> selected_people;
Run Code Online (Sandbox Code Playgroud)
我的代码:
for (int i = 0; i < people_list.getCount(); i++) {
              item_view = people_list.getAdapter().getView(i, null, null);
                chBox = (CheckBox) item_view.findViewById(R.id.checkBox);//your xml id value for checkBox.
                if (chBox.isChecked()) {
                    selected_people.add((PeopleDetails) people_list.getItemAtPosition(i));
                }
            }
        for(PeopleDetails person : selected_people){
            SmsManager sms = SmsManager.getDefault();
            sms.sendTextMessage(person.number, null, sms_message, null, null);        
            }
        ///and now need to write party to file.
Run Code Online (Sandbox Code Playgroud)
我在线上得到一个错误
for(PeopleDetails person:selected_people)
说"NullPointerException".我认为这意味着arraylist是null,并且无法弄清楚为什么它应该为null.我是否在课堂上声明错了?或者我的选择和添加方法有问题?
在我的Eclipse Android App中,我使用Date类型.我被警告说这是一种弃用的类型.这是否意味着我不能使用它,或者只是认为这是不好的做法?
谢谢您的帮助!!