반응형

코드


* 리소스 얻기

Button button1 = findViewById(R.id.button1);


* Listener 설정

button1.setOnClickListener( new View.OnClickListener() {

public void onClick(View v) {

// to do

}

});;



* Toast 사용

Toast.makeText(getApplicationContext(), "버튼클릭", Toast.LENGTH_SHORT).show();


* 브라우징

Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.naver.com"));

startActivity(mIntent);


* 전화

Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:/114"));startActivity(mIntent);


*갤러리

Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"));

startActivity(mIntent);


*종료

finish();


현재 날짜 구하기

Calendar cal = Calendar.getInstance();
int cYear = cal.get(Calendar.YEAR);
int cMonth = cal.get(Calendar.MONTH);
int cDay = cal.get(Calendar.DAY_OF_MONTH); 

datePicker.init(cYear, cMonth, cDay, new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
String date = Integer.toString(year) + "_" + Integer.toString(monthOfYear+1) + "_" + Integer.toString(dayOfMonth);
}
});



그외

상단 앱아이콘 설정

1) IMG: 72x72 png

res/drawable/ic_luncher.png

2) code : MainActivity

onCreate()

{

 getSupportActionBar().setDisplayShowHomeEnabled(true);

 getSupportActionBar().setIcon(R.drawable.ic_luncher);

}



반응형

'안드로이드' 카테고리의 다른 글

Android resource compilation failed  (3) 2019.02.23
Activity간 Object 공유- Parcelable  (0) 2019.02.21
EditText 포커스 문제  (0) 2019.02.13
Android Studio 단축키  (0) 2018.12.21
Android Studio 화면구성  (0) 2018.05.13

+ Recent posts