이 유형의 질문이 이전에 왔음을 알고 있으며, 나는 던져 버렸습니다.하지만 내가해야 할 마지막 부분을 얻지 못했습니다.사용자 정의 예외 Java를 처리 할 수 없습니다.
내 ExceptionClass
public class ProException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
public ProException(String message) {
super(message);
}
}
내 ActivityClass (ListView에 대한 안드로이드 사용자 정의 어댑터)
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
try {
if (convertView == null) {
vi = inflater.inflate(R.layout.pause_client_trigger_request_select_sku_list_row, null);
tvItemName = (TextView) vi.findViewById(R.id.list_row_ItemName);
} else {
tvItemName = (TextView) vi.findViewById(R.id.list_row_ItemName);
}
hmap = new HashMap<String, String>();
hmap = data.get(position);
tvItemName.setText(hmap.get(KEY_ItemName));
} catch (ProException ex) {
Log.i(Tag, ex.getMessage());
}
return vi;
}
지금 내가 원하는 것입니다.
이 경우에 발생하는 예외가있는 경우 try catch
예외. 내 custom class (ProException)
에 캡처해야합니다. 그러나 그것은 허락하지 않는다. 자바 이클립스 에디터 Unreachable catch block for ProException. This exception is never thrown from the try statement body
당신은 그것을 잡으려고'ProException'을 던져야합니다 ... –
던지다하지만 어떻게해야합니까? 여기에서 일어나는 예외를 잡아야합니다. – MDMalik
@MDMalik 안드로이드가 제공하는 Exception 클래스 (Exception (main 자바 클래스)가 아닌)를 확장해야한다고 생각합니다. – Ketan