Android:从JSON获取的数据在textview中没有显示完整

时间:2012-10-23 02:09:11

标签: android json textview

在我的应用中,我从JSON获取文本内容,并将该内容显示在文本视图中。但是,问题是文本没有显示完整,也没有格式化。我使用http://jsonformatter.curiousconcept.com/检查了我的JSON,它显示JSON有效。我已经打印了我在日志中收到的内容,但它已经完成了。甚至,在将其设置为textview并再次从它返回之后,我将获得完整的数据。但是,它没有显示完整的文字。

This is how it appears in the app:

我无法解决问题所在。 textview在scrollview中。

以下是我的代码: 基本活动

public class TIEBaseActivity extends MapActivity
{
//private ProgressDialog dialog;
public AlertDialog _alertDialog;
protected HeaderBar _headerBar;
protected FooterBar _footerBar;
protected LinearLayout _manager;
protected LinearLayout form;
protected TIEBaseActivity _self;

public void createDefaultView(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.basescreen);
    this._self=this;
    initView();
}   

public void loadFormFromResource(int resourceID)
{
    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(resourceID, null);
    _manager.addView(view);

}

public void loadDefaultForm()
{
    form=new LinearLayout(this);
    form.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
    form.setOrientation(LinearLayout.VERTICAL);
    form.setGravity(Gravity.CENTER);
    _manager.addView(form);
}

public void initView() 
{

    _headerBar = (HeaderBar) findViewById(R.id.baseHeaderBar);  
    _manager = (LinearLayout) findViewById(R.id.baseScrollContent);
    //_footerBar = (FooterBar) findViewById(R.id.baseFooterBar);

    _headerBar.view.setVisibility(View.GONE);
    //_footerBar.view.setVisibility(View.GONE);
}

protected void showScreen(Intent intent) {
    startActivity(intent);
}

public void setHeaderTitle(String title) {

    if (_headerBar!=null) {
        _headerBar.setTitle(title);
    }

}

public Handler progressCloseHandler = new Handler() {
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        if (_alertDialog != null)
            _alertDialog.cancel();
    }

};

private Handler alertViewHandler = new Handler() {

    public void handleMessage(Message msg) {
        String message=(String)msg.obj;
        AlertDialog.Builder _alert = new AlertDialog.Builder(TIEBaseActivity.this);
        _alert.setMessage(message)
        .setCancelable(false)
        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
            }
        });
        _alert.create().show();
    }
};

public void DisplayAlert(String message) {

    Message msg=Message.obtain(alertViewHandler);
    msg.obj=message;
    alertViewHandler.sendMessage(msg);

}

public void DisplayAlert(String message, int id) {  

    Message msg=Message.obtain(alertViewHandler);
    msg.obj=message;
    msg.what=id;
    alertViewHandler.sendMessage(msg);
}


private Handler closeViewHandler=new Handler() {
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        _self.finish();
    }
};

public void closeScreen() {

    closeViewHandler.sendMessage(Message.obtain(closeViewHandler));

}

public void openRating()
{
    Intent marketIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=com.dzo.tie"));
    startActivity(marketIntent);    
}

@Override
public void onConfigurationChanged(Configuration newConfig) {

    super.onConfigurationChanged(newConfig);
}

public void openShare()
{

    String mMailSubject = "OIE App. - Get the All Indian Events happening in Overseas"; 
    String mMailMessage = null;     
    mMailMessage = "Hi,\n I found this great Application. This application customize for Overseas Indian Events.";
    mMailMessage += "\n";
    mMailMessage += "Go to: https://market.android.com/details?id=com.dzo.oie";
    mMailMessage += ",\n Please visit: http://www.dotzoo.net to see more about Dotzoo Inc.";

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/*");              
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, ""+mMailSubject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, mMailMessage);
    startActivity(Intent.createChooser(emailIntent, "Share via..."));   

}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

BaseActivity的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="@color/white"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/baseLayout">

<com.dzo.tie.ui.HeaderBar
    android:id="@+id/baseHeaderBar" 
    android:layout_width="fill_parent"
    android:layout_height="50dp"/> 

<ScrollView 
    android:scrollbars="vertical"
    android:fillViewport="true"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">  

    <LinearLayout 
        android:id="@+id/baseScrollContent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" 
        android:gravity="center"
        android:layout_gravity="center" 
        android:layout_width="fill_parent">

    </LinearLayout> 
</ScrollView>  

我正在我的活动类中扩展此基本活动:

我的活动

public class TIEInfo extends TIEBaseActivity 
{
TextView txtTieInfo;
String contents;

private String infoUrl = "http://www.tradeineu.com/tie_app/aboutTie.php";
protected void onCreate(Bundle savedInstanceState) 
{
    super.createDefaultView(savedInstanceState);
    _headerBar.view.setVisibility(View.VISIBLE);
    super.setHeaderTitle("Info");
    init();
    new TIEInfoAsyncTask(getParent(), infoUrl, txtTieInfo).execute();
}//onCreate

public void init()
{
    loadFormFromResource(R.layout.tieinfo);
    txtTieInfo = (TextView)findViewById(R.id.txtTieInfo);
}//init
}//TIEInfo

我的活动布局

<?xml version="1.0" encoding="utf-8"?>
<TextView 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/txtTieInfo"
android:textSize="12sp"
android:textColor="@color/copper_gold"
android:lineSpacingExtra="5dp"/>

1 个答案:

答案 0 :(得分:1)

您需要滚动才能看到其余文字。 将您的textview放在scrollView中,它就可以了。