0
我正嘗試從適配器重新加載MainActivity。請看以下代碼:重新加載活動時出現閃爍
activity = (Activity) context;
activity.finish();
activity.overridePendingTransition(0, 0);
Intent intent =((Activity) context).getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
context.startActivity(intent);
activity.overridePendingTransition(0, 0);
的問題是,即使是添加此代碼塊後,閃爍的動畫仍是活動的重裝過程中出現的。
在適配器內部,我顯示了一個對話框。按下按鈕後,對話框將導致重新加載活動。
內onBindViewHolder():
viewHolder.txtv_name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
int_timer = 0;
tickValue = true;
timerGroupChatHistory.start();
getChatHistory(alst_Dealitem.get(i));
}
});
裏面的聊天記錄,我打電話ShowChatDialog():
public void show_chatDialog(final ArrayList<chatObject> alst_chatHistoryList, final String refNumber)
{
final Dialog dlg_dialog = new Dialog(context, R.style.Theme_Dialog);
// dialog.setCancelable(false);
dlg_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = dlg_dialog.getWindow();
if (window == null) return;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dlg_dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
lp.gravity = Gravity.CENTER;
dlg_dialog.getWindow().setAttributes(lp);
//dialog.setContentView(R.layout.new_field_quote_entry_dialog);
dlg_dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dlg_dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
//dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
dlg_dialog.setContentView(R.layout.chat_history_dialog);
final RecyclerView rvw_chatHistoryList = (RecyclerView)dlg_dialog.findViewById(R.id.chatHistoryList);
final EditText etxt_chatText = (EditText)dlg_dialog.findViewById(R.id.chat_type);
final LinearLayout lnrl_mainLayout = (LinearLayout)dlg_dialog.findViewById(R.id.dialog_main_layout);
TextView txtv_send = (TextView) dlg_dialog.findViewById(R.id.chat_send);
TextView txtv_title = (TextView)dlg_dialog.findViewById(R.id.chat_text) ;
LinearLayout lnrl_back = (LinearLayout) dlg_dialog.findViewById(R.id.chat_backbutton) ;
txtv_title.setText(refNumber);
lnrl_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.finish();
activity.overridePendingTransition(0, 0);
Intent intent =((Activity) context).getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
context.startActivity(intent);
activity.overridePendingTransition(0, 0);
}
});
有什麼我失蹤?請幫忙。提前致謝。
發佈更多代碼。 – Anonymous
@匿名:請檢查更新的代碼。 –