我正在使用 来AlarmManager将 a 传递PendingIntent给我的BroadcastReceiver5 分钟后。现在,我想DialogFragment向用户显示一个,位于警报响起时用户可能使用的任何应用程序之上。例如,如果用户在闹钟响起时正在使用 Chrome,则我的DialogFragment窗口应该在用户的 Chrome 窗口上方弹出。
我最终得到的是以DialogFragment我的应用程序的空白活动作为背景显示(如下图所示)
https://i.stack.imgur.com/Vz9IZ.png
这是我在我的 中使用的代码BroadcastReceiver,用于启动FragmentActivity第一个:
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
Intent hardReminderIntent = new Intent(context, AlarmHardActivity.class);
hardReminderIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(hardReminderIntent);
}
}
Run Code Online (Sandbox Code Playgroud)
接下来,从这个活动中,我弹出DialogFragment:
public class AlarmHardActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fm = getSupportFragmentManager();
AlarmHardDialog editNameDialog = new AlarmHardDialog();
editNameDialog.show(fm, "fragment_dialog");
//setContentView(R.layout.activity_alarm_hard); …Run Code Online (Sandbox Code Playgroud) 我已经ListView使用自定义实现在我的应用程序中实现了CursorAdapter.我的问题是,每当我急速滚动到列表的底部(启动应用程序后),我有时最终会将所有ListView项目相互重叠.如果我向上滚动或触摸其中一个项目,它们将被正确排列.
以下是我快速向下滚动的方式:http: //i.stack.imgur.com/cTcfD.png
下面是它的外观时,我选择- 荷兰国际集团的项目之一: http://i.stack.imgur.com/ZTRSt.png
这是我的XML ListView:
<ListView
android:id="@+id/all_reminders_list"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_alignParentLeft="true"
android:clickable="true"
android:dividerHeight="1.0sp"
android:animateLayoutChanges="true">
Run Code Online (Sandbox Code Playgroud)
这newView(..)是我的自定义CursorAdapter 的方法:
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View view = inflater.inflate(R.layout.view_list_item, parent, false);
return view;
}
Run Code Online (Sandbox Code Playgroud)
这是bindView(..)方法:
public void bindView(View view, Context context, Cursor cursor) {
TextView whatTextView = (TextView) view.findViewById(R.id.item_what_text);
whatTextView.setText(cursor.getString(1));
TextView whenTextView = (TextView) view.findViewById(R.id.item_when_text);
if(cursor.getInt(9) != 0) // …Run Code Online (Sandbox Code Playgroud)