将数据保存到电子邮件中:

发布于 2024-11-07 18:50:24 字数 434 浏览 9 评论 0原文

将来自多个活动的编辑文本、文本视图、微调器选择和复选框的数据保存到电子邮件中:

我已经在使用:

Intent EmailSend = new Intent(android.content.Intent.ACTION_SEND);
    EmailSend.setType("plain/text");
    EmailSend.putExtra(android.content.Intent.EXTRA_TEXT,
      "Pretext"+edittext.getText().toString());

放置字符串不适用于 .java 中未列出的项目 当我使用最后一行时,我收到错误消息 -edittext 无法解析 -

以及如何从复选框和获取数据; spinner

我将在 8 个活动中将大约 80 个项目编译到此电子邮件中

Save data from edit texts, text views, spinner selections, and checkboxes from multiple activities into an email:

I am already using:

Intent EmailSend = new Intent(android.content.Intent.ACTION_SEND);
    EmailSend.setType("plain/text");
    EmailSend.putExtra(android.content.Intent.EXTRA_TEXT,
      "Pretext"+edittext.getText().toString());

the put string is not working for items not listed in the .java
When I use the last line in that i get error saying -edittext cannot resolved-

and how to get data from checkbox & spinner

I will have 80 or so items to compile to this email over 8 activities

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅此而已 2024-11-14 18:50:24

我写了一个片段来使其自动化一点:

ViewGroup     root = (ViewGroup) ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
StringBuilder str  = new StringBuilder();

public void extractText(ViewGroup root, StringBuilder str){
    int count = root.getChildCount();
    for(int i = 0; i < count; i++) {
        View v = root.getChildAt(i);

        if(v instanceof Spinner) {
            str.append(i).append(" Spinner: ").append(((Spinner) v).getSelectedItem());
        } else if(v instanceof TextView) {
            str.append(i).append(" TextView: ").append(((TextView) v).getText());
        } else if(v instanceof CheckBox) {
            str.append(i).append(" Checkbox: ").append(((CheckBox) v).isChecked());
        }else if(v instanceof ViewGroup){
            extractText((ViewGroup)v, str);
        }
    }
}

I wrote a snippet to automate it a little:

ViewGroup     root = (ViewGroup) ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
StringBuilder str  = new StringBuilder();

public void extractText(ViewGroup root, StringBuilder str){
    int count = root.getChildCount();
    for(int i = 0; i < count; i++) {
        View v = root.getChildAt(i);

        if(v instanceof Spinner) {
            str.append(i).append(" Spinner: ").append(((Spinner) v).getSelectedItem());
        } else if(v instanceof TextView) {
            str.append(i).append(" TextView: ").append(((TextView) v).getText());
        } else if(v instanceof CheckBox) {
            str.append(i).append(" Checkbox: ").append(((CheckBox) v).isChecked());
        }else if(v instanceof ViewGroup){
            extractText((ViewGroup)v, str);
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文