短信收件箱 - 的TextView [英] Sms Inbox - TextView

查看:125
本文介绍了短信收件箱 - 的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我创建的短信应用巫婆向我展示内容Inbox.I的我使用的TextView但问题screen.I不能看到所有短信,但屏幕尺寸只有短信。我不能滚动down.How我可以看到所有短信与向下滚动/向上?抑或是支持的TextView?
对不起,我的英语我是捷克。
谢谢

来源$ C ​​$ C:

 进口android.app.Activity;
进口android.database.Cursor;
进口android.net.Uri;
进口android.os.Bundle;
进口android.widget.TextView;    公共类Mynew延伸活动{      @覆盖
      公共无效的onCreate(捆绑savedInstanceState){
          super.onCreate(savedInstanceState);
          TextView的视图=新的TextView(本);
          乌里uriSMSURI = Uri.parse(内容://短信/收件箱);
          光标CUR = getContentResolver()查询(uriSMSURI,NULL,NULL,NULL,NULL);
          字符串短信=;
          而(cur.moveToNext()){
              字符串的地址= cur.getString(cur.getColumnIndex(地址));
              绳体= cur.getString(cur.getColumnIndexOrThrow(身体));
              短信+ =发件人地址+ +:+机身+\\ n;
          }
          view.setText(SMS);
          的setContentView(视图);
      }
    }

XML:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    >
<的TextView
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT    机器人:文字=@字符串/你好
    机器人:ID =@ + ID / row_entry/>/>
< / LinearLayout中>

清单:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      包=New.test
      安卓版code =1
      机器人:=的versionName1.0>
    <应用机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME>
        <活动机器人:MynewNAME =
                  机器人:标签=@字符串/ APP_NAME>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;    < /用途><使用许可权的android:NAME =android.permission.READ_SMS>< /使用许可权>
< /清单>


解决方案

环绕用滚动型TextView的。

或者更有可能你想,如果你需要做的事情与列表有用的东西:了解列表视图

Hello i am created Sms app witch shows me content of Inbox.I am using TextView but there is problem with screen.I can't see all sms but only sms of screen size.. I can't scroll down.How can i see all sms with scroll down / up? Or is it supported on TextView? Sorry for my english i am czech . Thanks

Source code:

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

    public class Mynew extends Activity {

      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          TextView view = new TextView(this);
          Uri uriSMSURI = Uri.parse("content://sms/inbox");
          Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null);
          String sms = "";
          while (cur.moveToNext()) {
              String address = cur.getString(cur.getColumnIndex("address"));
              String body = cur.getString(cur.getColumnIndexOrThrow("body"));
              sms += "From :" + address  + " : " + body+"\n";         
          }
          view.setText(sms);
          setContentView(view);
      }
    }

Xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@string/hello"
    android:id="@+id/row_entry"/>

/>


</LinearLayout>

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="New.test"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Mynew"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>



<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
</manifest> 

解决方案

Surround the TextView with a ScrollView.

Or more likely what you want if you need to do something useful with the list : Learn about ListViews

这篇关于短信收件箱 - 的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆