logcat に int を出力する適切な方法がわかりません。APIドキュメントは意味がありません。
私はこれがそれを行うべきだと感じます:
package com.example.conflip;
import java.util.Random;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
flip();
}
public int flip() {
Random randomNumber = new Random();
int outcome = randomNumber.nextInt(2);
Log.d(outcome);
return outcome;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
ただし、エラーのみが表示されますThe method d(String, String) in the type Log is not applicable for the arguments (int)
int を文字列にキャストする必要がありますか? もしそうなら、どのように?
アップデート:
以下の解決策はすべて機能しますが、DDMS でハードウェア デバイスを選択するまで、LogCat は出力を表示しません。