LinearLayout
Orientation horizontal
LinearLayout
layout_height wrap_content
layout_width fill_parent
orientation vertical
layout_gravity center
id blank
id @+id/myTextView
text @string/message_start
textColor @color/text_color
layout_margin 20dp
layout_height wrap_content
layout_width wrap_parent
layout_gravity center
src\MainHelloButton.java
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.util.Log;
import android.view.View;
public class MainHelloButton extends Activity{
private int mPressCount;
private static final String TAG = "MainHelloButton";
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button myButton = (Button) findViewById(R.id.my_button);
final TextView myTextView = (TextView) findViewById(R.id.my_text_view);
myButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
mPressCount++;
Resources res = getResources();
string msg = res.getString(R.string.message_format, mPressCount);
myTextView.setText(msg);
Log.d(TAG, "Log a button click press = " + mPressCount);
}
});
}
}
Change app icon in AndroidManifest.xml file
Log.d ~ debug
Log.wtf ~ what a terrible failure
Log.f ~ failure
Window -> Show View -> Other -> Android -> LogCat
No comments:
Post a Comment