조각 활동의 데이터를 다른 클래스로 전달하려고합니다. 그러나 "생성자 의도 (새 View.OnClickListener() {}, 클래스)가 정의되지 않았습니다."라는 오류가 발생합니다. 이 코드 여기Android - 생성자가 정의되지 않았습니다. 오류
'Intent intent = new Intent(this, WebSocket_Connector.class);'
와
는 code..how 내가 'ID'문자열 값을 전달할 수있다? 텐트 constrcutor의
public class Myoffers_Fragment extends Fragment {
private final WebSocketConnection mConnection = new WebSocketConnection();
public static Fragment newInstance(Myoffers context, int pos, float scale)
{
Bundle b = new Bundle();
b.putInt("pos", pos);
b.putFloat("scale", scale);
return Fragment.instantiate(context, Myoffers_Fragment.class.getName(), b);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (container == null) {
return null;
}
LinearLayout l = (LinearLayout) inflater.inflate(R.layout.mf, container, false);
int pos = this.getArguments().getInt("pos");
TextView tv = (TextView) l.findViewById(R.id.text);
tv.setText("Product " + pos);
ImageButton product_photo = (ImageButton) l.findViewById(R.id.myoffer_image);
if (pos == 0) {
product_photo.setImageResource(R.drawable.myoffers_0);
product_photo.setOnClickListener(new ImageButton.OnClickListener(){
public void onClick(View v){
String id1 = "Product0";
Intent intent = new Intent(this, WebSocket_Connector.class);
intent.putExtra("KeyToAccessData", id1);
startActivity(intent);
Log.d(TAG, "Current product is : " + id1);
Log.d(TAG, id1 + "is sent to server!");
}
});
}
감사를 시도 해달라고. 그것은 작동합니다. – user2500696
환영합니다 – Blackbelt
마음에 들지 않으면 "Android - Autobahn Websocket 보내는 메시지 오류 (NullPointerException)"질문을 확인해주세요. .. 아무도 대답하지 않습니다. :( – user2500696