0

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

这是它在应用程序中的显示方式:

我没有找到问题所在。文本视图在滚动视图内。

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

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"/>
4

1 回答 1

1

您需要滚动才能查看其余文本。将你的 textview 放在一个 scrollView 里面就可以了。

于 2012-10-23T02:20:42.270 回答