开发者

How to print EditText content to the log? [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

How to print the data which is coming from the edittext?

final ViewGroup layout6 = (ViewGroup) LayoutInflater.from(Menus.this)
    .inflate(R.layout.beefkabobsandwhichdialog, null);

AlertDialog.Builder builder6 = new AlertDialog.Builde开发者_开发技巧r(Menus.this);
builder6.setView(
    LayoutInflater.from(Menus.this)
        .inflate(R.layout.beefkabobsandwhichdialog, null));
builder6.setPositiveButton("Add2Order",new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
        String str = ((EditText)layout6.findViewById(R.id.quantityedittext1))
            .getText().toString();
        System.out.println(str);
    }
});


What you have written there will print your result out in Logcat but it will be hard to see. There are two things you could try:

Replace

System.out.println(str);

with

System.out.println("****************************************************");
System.out.println(str);       
System.out.println("****************************************************");

It will be hard to miss that.

What people usually do though, is print out in Logcat format. Here's the code on how to do it:

Log.i(tag, str);

'tag' here is a string and it will show in a left-hand column in Logcat. This makes it extremely easy to identify as you can add a filter to just show the log with your selected tag. This is the recommended way to do it, but you can use the standard System.out.println(). It does work, just really hard to see.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜