본문내용
enu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {//메뉴아이템이 선택되었을때
// TODO Auto-generated method stub
switch(item.getItemId()) {
case 0:
if (webview.canGoBack()){
webview.goBack();//뒤로갈수있다면 뒤로감
url.setText(webview.getUrl()); //url을 현재 웹뷰에 보이는 url로 세팅
}
else //뒤로 갈수 없으면
Toast.makeText(getBaseContext(),\"뒤로 갈 수 없습니다.\",Toast.LENGTH_SHORT).show();
break;
case 1:
if (webview.canGoForward()) { //앞으로 갈 수있으면
webview.goForward(); //앞으로 가기
url.setText(webview.getUrl()); //url을 현재 웹뷰에 보이는 url로 세팅
}
else //앞으로 갈 수 없으면
Toast.makeText(getBaseContext(), \"앞으로 갈 수 없습니다.\", Toast.LENGTH_SHORT).show();
break;
case 2: //북마크를 눌렀을 때
final CharSequence[] items = {\"http://www.naver.com\", \"http://www.yahoo.com\", \"http://www.google.com\",\"http://www.twitter.com\",\"http://www.myspace.com\",\"http://www.ssu.ac.kr\"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(\"북마크리스트\");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
url.setText((String) items[item]);//url을 현재 웹뷰에 보이는 url로 세팅
webview.loadUrl((String) items[item]); //items[item]을 스트링으로 변환해서 webview를 띄어줌
//Toast.makeText(getApplicationContext(),items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
Toast.makeText(getBaseContext(), \"Bookmarks\",
Toast.LENGTH_SHORT).show();
alert.show();
break;
}
return super.onOptionsItemSelected(item);
}
}
main.xml
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
>
android:orientation=\"horizontal\"
android:layout_width=\"fill_parent\"
android:layout_height=\"wrap_content\"
>
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:layout_weight=\"1.0\"
/>
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:text=\"Go\"
android:textSize=\"20px\"
android:textStyle=\"bold\" />
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:layout_weight=\"1.0\"
/>
AndroidManifest.xml
package=\"com.ssu.WebBrowser\"
android:versionCode=\"1\"
android:versionName=\"1.0\">
android:label=\"@string/app_name\">
실행켭쳐
www.naver.com 북마크 클릭시
backward 클릭시
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {//메뉴아이템이 선택되었을때
// TODO Auto-generated method stub
switch(item.getItemId()) {
case 0:
if (webview.canGoBack()){
webview.goBack();//뒤로갈수있다면 뒤로감
url.setText(webview.getUrl()); //url을 현재 웹뷰에 보이는 url로 세팅
}
else //뒤로 갈수 없으면
Toast.makeText(getBaseContext(),\"뒤로 갈 수 없습니다.\",Toast.LENGTH_SHORT).show();
break;
case 1:
if (webview.canGoForward()) { //앞으로 갈 수있으면
webview.goForward(); //앞으로 가기
url.setText(webview.getUrl()); //url을 현재 웹뷰에 보이는 url로 세팅
}
else //앞으로 갈 수 없으면
Toast.makeText(getBaseContext(), \"앞으로 갈 수 없습니다.\", Toast.LENGTH_SHORT).show();
break;
case 2: //북마크를 눌렀을 때
final CharSequence[] items = {\"http://www.naver.com\", \"http://www.yahoo.com\", \"http://www.google.com\",\"http://www.twitter.com\",\"http://www.myspace.com\",\"http://www.ssu.ac.kr\"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(\"북마크리스트\");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
url.setText((String) items[item]);//url을 현재 웹뷰에 보이는 url로 세팅
webview.loadUrl((String) items[item]); //items[item]을 스트링으로 변환해서 webview를 띄어줌
//Toast.makeText(getApplicationContext(),items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
Toast.makeText(getBaseContext(), \"Bookmarks\",
Toast.LENGTH_SHORT).show();
alert.show();
break;
}
return super.onOptionsItemSelected(item);
}
}
main.xml
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
>
android:layout_width=\"fill_parent\"
android:layout_height=\"wrap_content\"
>
android:layout_height=\"wrap_content\"
android:layout_weight=\"1.0\"
/>
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:text=\"Go\"
android:textSize=\"20px\"
android:textStyle=\"bold\" />
android:layout_height=\"wrap_content\"
android:layout_weight=\"1.0\"
/>
AndroidManifest.xml
android:versionCode=\"1\"
android:versionName=\"1.0\">
실행켭쳐
www.naver.com 북마크 클릭시
backward 클릭시
키워드
추천자료
- 국내 스마트폰 산업의 활성화를 위한 과제
- [디지털 산업]디지털 산업의 현황과 문제점 및 디지털 산업의 발전방향 제언 [2012년 A+추천]
- 엠에스엔-다국적 기업의 해외진출 실패사례 분석,MSN의 국내시장 진출,SWOT을 통한 실패요인 ...
- 안드로이드 정보보호 어플(보안 앱) - 주석, 시스템분석설계도 포함 -
- MSN (Microsoft Network)엠에스엔,다국적 기업의 해외진출 실패사례 분석,MSN의 국내시장 진...
- 2016년 1학기 컴퓨터의이해 중간시험과제물 공통(스마트폰 운영체제, QR 코드)
- (국제경영학 공통) 2016년 한국의 인터넷 검색시장에서 구글이 크게 성장한 이유를 설명하시...
- 방송대 중간과제 IT와 경영정보시스템 이상의 기술과 참고사항들을 기준으로 구글이 테블릿(...
- 아마존 Amazon 사업다각화 경영전략 사례
소개글