我已经在我的应用程序中使用FirebaseUI实现了一个RecyclerView,它将我带到一个特定的活动。我将此活动称为TicketDetailActivity。只有当我尝试将意图指向此活动并且适用于任何其他活动时,应用程序才会崩溃。可能是什么原因?
我还必须补充一点,我复制了'TicketDetailActivity'来自另一个项目。那可能是与之相关的问题吗?
我的Recyclerview Java代码:
FirebaseRecyclerAdapter<Ticket_list, TicketsActivity.TicketsViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Ticket_list, TicketsActivity.TicketsViewHolder>(
Ticket_list.class,
R.layout.ticket_item_layout,
TicketsActivity.TicketsViewHolder.class,
mEventsDatabase
) {
@Override
protected void populateViewHolder(TicketsActivity.TicketsViewHolder viewHolder, final Ticket_list model, int position) {
final String event_id = getRef(position).toString();
viewHolder.setEventName(model.getName());
viewHolder.setEventAddress(model.getAddress());
viewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Toast.makeText(TicketsActivity.this, "Clicked on "+model.getName()+" ID: "+event_id, Toast.LENGTH_LONG).show();
try{
Intent TicketDetailIntent = new Intent(TicketsActivity.this, TicketDetailActivity.class);
startActivity(TicketDetailIntent);
//finish();
}
catch(Exception e)
{
Log.e("CRASH", "onRecyclerViewCLick: Failed");
Toast.makeText(TicketsActivity.this, "Couldn't go to the window", Toast.LENGTH_LONG).show();
}
}
});
}
};
Tickets_list.setAdapter(firebaseRecyclerAdapter);
}
TicketDetailActivity:
package vision.google.com.unicesscustomer.TicketsPage.BookingWorkFlow;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import vision.google.com.unicesscustomer.R;
public class TicketDetailActivity extends AppCompatActivity {
private DatabaseReference mBlockedTicket, mTicketCount;
Button book;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
book = (Button) findViewById(R.id.book_btn);
mTicketCount = FirebaseDatabase.getInstance().getReference().child("Total Ticket Count");
mBlockedTicket = FirebaseDatabase.getInstance().getReference().child("Ticket blocks").child("Arjun");
book.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent startIntent = new Intent(TicketDetailActivity.this, TicketInputActivity.class);
startActivity(startIntent);
finish();
/* // -------- UPDATE TICKET COUNT ------- //
mTicketCount.runTransaction(new Transaction.Handler() {
@Override
public Transaction.Result doTransaction( MutableData mutableData) {
if(mutableData.getValue()!=null)
{
mutableData.setValue((Long)mutableData.getValue()-1);
}
return Transaction.success(mutableData);
}
@Override
public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {
Intent startIntent = new Intent(TicketDetailActivity.this, TicketInputActivity.class);
startActivity(startIntent);
finish();
}
});
// ------- UPDATE TO BLOCKED TICKETS ------ //
mBlockedTicket.setValue("Blocked");*/
}
});
}
}
TicketDetailActivity的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="vision.google.com.unicesscustomer.TicketsPage.BookingWorkFlow.TicketDetailActivity">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="53dp"
android:layout_marginTop="61dp"
android:text="Name" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginTop="34dp"
android:text="Date and Time" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView4"
android:layout_below="@+id/textView4"
android:layout_marginTop="31dp"
android:text="Location" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/textView3"
android:layout_below="@+id/textView5"
android:layout_marginTop="32dp"
android:text="About" />
<Button
android:id="@+id/book_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="91dp"
android:text="Book tickets"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
My Manifest文件夹:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="vision.google.com.unicesscustomer">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="FIDL"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".HomePage.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Login_and_Register.StartActivity" />
<receiver android:name=".HomePage.Changing_QR_widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/changing__qr_widget_info" />
</receiver>
<activity
android:name=".HomePage.Pop"
android:theme="@style/AppTheme.CustomTheme" />
<activity android:name=".QRPage.QRActivity" />
<activity android:name=".TicketsPage.TicketsActivity" />
<activity android:name=".TicketsPage.IndividualTicketActivity" />
<activity android:name=".TicketsPage.TicketSummaryPage">
<activity android:name=".TicketsPage.BookingWorkFlow.ConfirmedBookingActivity" />
<activity android:name=".TicketsPage.BookingWorkFlow.TicketBlockedActivity" />
<activity android:name=".TicketsPage.BookingWorkFlow.TicketDetailActivity" />
<activity android:name=".TicketsPage.BookingWorkFlow.TicketInputActivity" />
</activity>
</application>
</manifest>
答案 0 :(得分:0)
原来我的清单中的这一行:
<activity android:name=".TicketsPage.TicketSummaryPage">
应该是
<activity android:name=".TicketsPage.TicketSummaryPage"/>
现在效果很好!