개속 실행이 안되네요;;ㅠㅠ
에러내용 첨부파일 붙였습니다.
-------------------------ToastTest.java 파일---------------------------------
package exam.CustomView;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import exam.CustomView.*;
public class ToastTest extends Activity {
Toast mToast = null;
int count;
String str;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.toasttest);
findViewById(R.id.shortmsg).setOnClickListener(mClickListener);
findViewById(R.id.longmsg).setOnClickListener(mClickListener);
findViewById(R.id.count1).setOnClickListener(mClickListener);
findViewById(R.id.count2).setOnClickListener(mClickListener);
findViewById(R.id.customview).setOnClickListener(mClickListener);
}
Button.OnClickListener mClickListener = new Button.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.shortmsg:
Toast.makeText(ToastTest.this, "잠시 나타나는 메시지",
Toast.LENGTH_SHORT).show();
break;
case R.id.longmsg:
Toast.makeText(ToastTest.this, "조금 길게 나타나는 메시지",
Toast.LENGTH_LONG).show();
break;
case R.id.count1:
str = "현재 카운트 = " + count++;
if (mToast != null) {
mToast.cancel();
}
mToast = Toast.makeText(ToastTest.this, str, Toast.LENGTH_SHORT);
mToast.show();
break;
case R.id.count2:
str = "현재 카운트 = " + count++;
if (mToast == null) {
mToast = Toast.makeText(ToastTest.this, str, Toast.LENGTH_SHORT);
} else {
mToast.setText(str);
}
mToast.show();
break;
case R.id.customview:
LinearLayout linear = (LinearLayout)View.inflate(ToastTest.this,
R.layout.toast, null);
Toast t2 = new Toast(ToastTest.this);
t2.setView(linear);
t2.show();
break;
}
}
};
}
--------------------------끝--------------------------------------------------
--------------------toasttest.xml-----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/shortmsg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="짧은 메시지"
/>
<Button
android:id="@+id/longmsg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="긴 메시지"
/>
<Button
android:id="@+id/count1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="카운트 연속 출력"
/>
<Button
android:id="@+id/count2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="카운트 연속 출력2"
/>
<Button
android:id="@+id/customview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="커스텀 뷰 표시"
/>
</LinearLayout>
----------------------------끝------------------------------------
--------------------toast---------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toastlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/pride"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pride is a pretty car"
/>
</LinearLayout>
-----------------------------끝-------------------------------
첨부하신 이미지를 봤는데요 에러내용은 ClassNotFoundException 이군요.
findViewById(R.id.shortmsg).setOnClickListener(mClickListener); <- 제 생각인데 요 부분을 요렇게 작성을 하시면 우선 찾고자하는 View가 TextView인지 Button인지 EditorView인지를 알 수 가 없습니다.
코드를 단축시키시려고 하신 거 같은데요
그럴라면 ((TextView) findViewById(R.id.shortmsg)).setOnClickListener(mClickListener); <- 요렇게 캐스팅을 하셔야 될 것 같습니다.
도움이 되었으면 좋겠네요 :)




로그를 첨부하실때는 ...
adb logcat > a.txt 이런식으로 로그를 파일로 저장한 붙이는게 다른 사람이 도와주는데 있어서 편리하지 않을가 싶네요.
첨부사진에 내용이 잘 나오도록 한것도 아니고, 코드에 중간중간 로그가 있어 어디부근인지 나오는것도 아니고,
어떻게 도와달라는건지 난감하네요...