1

私はこのようなコードを持っています:

public class myAcitvity extends Activity {
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_mine);
       // Want a text to appear on activity screen after this activity creation , but not a toast.
     }
}

アクティビティが作成されたら、またはをjsp使用するように静的テキストを表示します。Androidでそれを行うにはどうすればよいですか?<c: out>out.print()

4

3 に答える 3

1

activity_mine を次のように変更します。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

public class myAcitvity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_mine);
   TextView t = (TextView)findViewById(R.id.textView1);
   t.setText("some static text");
 }

}

于 2013-07-19T07:58:41.153 に答える
0

コンソールに出力するには、次を使用します。

Log.i("My Error", "Oops, that didn't go so well..."); 

アクティビティに何かを表示したい場合は、Activity_mine.xml レイアウト ファイルに TextView のようなものを追加できます。

 <TextView android:text="My Text"
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</TextView>

または onCreate() メソッドでプログラムでビューを作成します。

TextView textView = new TextView(getApplicationContext());
textView.setText("My text");
layout.addView(TextView, layoutParams); <- get your parent layout and create params
于 2013-07-19T08:02:13.337 に答える
0

ログを使用できます。しかし、あなたの必要性は別のものだと思います。

于 2013-07-19T07:58:55.250 に答える