我正在从消防站取一件物品。但是当我尝试将clicklistner
放在文本视图上时,它不起作用。我还尝试过设置一个断点,但从未达到。
private static final String EXCITING_KEY_TARGET = "eo_target";
private TextView eo_target;
eo_target = (TextView) findViewById(R.id.m_eo_target);
eo.get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
testing(documentSnapshot);
}
private void testing(DocumentSnapshot documentSnapshot) {
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
TastyToast.makeText(getApplicationContext(), "Failed to Load Image", TastyToast.LENGTH_SHORT, TastyToast.ERROR);
Log.d(TAG, e.toString());
}
});
@Override
public void onStart() {
super.onStart();
eo.addSnapshotListener(new DetailsExcitingOffer(), new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@javax.annotation.Nullable DocumentSnapshot documentSnapshot, @javax.annotation.Nullable FirebaseFirestoreException e) {
if (e != null) {
return;
}
if (documentSnapshot.exists()) {
eo_target.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse(EXCITING_KEY_TARGET);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (intent.resolveActivity(getApplicationContext().getPackageManager()) != null) {
v.getContext().startActivity(intent);
}
}
});
}