我希望能够在用户开始更改时检测到datepicker上的更改.但是,我不想使用datrpickerdialog.有没有人知道为什么在更改datepicker上的日期时onDateSet(DatePicker arg0,int arg1,int arg2,int arg3)不会触发?
我对此表示高度赞赏.干杯
这是我的代码的简化版本:
public class AddItem extends Activity implements OnDateChangedListener,OnDateSetListener{
DatePicker start ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.entryelements);
start = (DatePicker) findViewById(R.id.start);
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
" thiv view"+year,
Toast.LENGTH_LONG).show();
Log.v("indatechange", "ok");
}
@Override
public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
" thiv view"+arg0,
Toast.LENGTH_LONG).show();
Log.v("indatechange", "ok");
}
Run Code Online (Sandbox Code Playgroud)
}
我想知道有没有办法在我的应用程序中更改和自定义语音识别对话框的样式?
我用这个代码,它完成了吗?public void onReadyForSpeech(Bundle params){proccessTXT.setText("现在说吧!"); }
public void onReadyForSpeech(Bundle params) {
proccessTXT.setText("Speak now!");
}
@Override
public void onBeginningOfSpeech() {
}
@Override
public void onRmsChanged(float rmsdB) {
}
@Override
public void onBufferReceived(byte[] buffer) {
}
@Override
public void onEndOfSpeech() {
proccessTXT.setText("Waiting");
}
@Override
public void onError(int error) {
proccessTXT.setText(R.string.toast_disconnect);
}
@Override
public void onResults(Bundle results) {
match_text_dialog = new Dialog(MainActivity.this);
match_text_dialog.setContentView(R.layout.dialog_maches_flag);
match_text_dialog.setTitle(R.string.selection_list);
textlist = (ListView) match_text_dialog.findViewById(R.id.list);
matches_text = getIntent().getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, matches_text);
textlist.setAdapter(adapter);
textlist.setOnItemClickListener(new AdapterView.OnItemClickListener() { …Run Code Online (Sandbox Code Playgroud) 我想根据我拥有的生命周期状态处理我的数据。
比如我想做点什么,当申请恢复的时候。我怎样才能知道我的应用程序现在处于哪个状态?感谢帮助。
我有一个简单的DialogFragment,其中包含 3EditText和Button. 我已经设置了其主布局的layout_width 350dp,但是当我运行该项目时,它会显示得很窄。
这是我的 DialogFragment XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:animateLayoutChanges="true"
android:background="#AFE6FF"
android:orientation="vertical"
android:padding="24dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:id="@+id/layout_mobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/et_mobile"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/layout_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/et_title"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/layout_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layout_title">
<EditText
android:id="@+id/et_body"
android:layout_width="match_parent"
android:layout_height="150dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" …Run Code Online (Sandbox Code Playgroud) 在ConstraintLayout我需要假设两个视图作为一个组并将该组中心水平放置在父级中,如下图所示:
这是我的 xml 代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<TextView
android:id="@+id/view_a"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:background="@android:color/holo_orange_dark"
android:gravity="center"
android:text="View A"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/view_b"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/view_b"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:background="@android:color/holo_red_light"
android:gravity="center"
android:text="View B"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/view_a"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我已经看过这个答案,但是当两个视图具有相同的宽度时它有效。我的视图宽度不一样,所以Guideline不起作用!
我怎样才能做到这一点?
android centering android-xml android-constraintlayout constraint-layout-chains
我有一个 RecyclerView 和一个具有 Person 模型的 ArrayList 的适配器。当应用程序启动时,我在 EditText 中输入名称并按下按钮:
但是当我在活动中记录 personList 数据时,结果是:
personList: Item 0 -----> Alireza
personList: Item 1 -----> Tohid
personList: Item 2 -----> Alireza
Run Code Online (Sandbox Code Playgroud)
第一个项目被删除,最后一个项目在第一个项目中重复。(我的适配器更复杂,但我减少了代码和视图以专注于主要问题)
适配器布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
适配器类:
public class TestAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Person> mList;
private View.OnClickListener listener;
public TestAdapter(ArrayList<Person> mList, View.OnClickListener listener) {
this.mList …Run Code Online (Sandbox Code Playgroud) 我想以Settings -> Application -> manage application -> Application info编程方式开始管理应用程序 ( ) 屏幕。我做不到。谁能帮帮我吗?
提前致谢。
我在ViewPager周围有一个SwipeRefreshLayout.ViewPager加载的片段包含ScrollViews.当我向下滚动它工作正常,但当我向上滚动时,SwipeRefreshLayout激活而不让ScrollView首先向上滚动.如何确保ScrollView具有优先权?
当SwipeRefreshLayout位于ScrollView外部的各个片段中时,它工作正常,但我需要它在ViewPager周围的活动本身.
以下是相关布局:
活动:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EEEEEE"
android:fitsSystemWindows="true">
<include layout="@layout/toolbar" />
<io.karim.MaterialTabs
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/primary"
app:mtIndicatorColor="@color/icons"
app:mtIndicatorHeight="2dp"
app:mtSameWeightTabs="true"
app:mtPaddingMiddle="false"
app:mtTextColorSelected="@color/icons"
android:textColor="@color/icons"
android:elevation="4dp"
tools:ignore="UnusedAttribute" />
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeRefresh"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
ViewPager加载的片段(有5个标签,每个标签都有一个):
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="me.sargunvohra.android.purduediningcourts.presenter.MenuFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
>
<!-- Content snipped for brevity -->
<!-- blah blah... lots of content here -->
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
android android-layout android-fragments android-scrollview android-viewpager
当应用程序处于前台或后台时,我将使用自定义单击操作发送推送通知以设置onClick通知以Activity在我的项目中打开一个确切的消息。在所有帖子和评论中都写到无法从控制台发送带有自定义单击操作的通知,但在控制台的“高级选项”中,可以设置自定义数据键和值。
为什么应该不可能设置click_action键及其值?
如果可能,请告诉我我该怎么做。我的意思是确切的意图过滤器代码是什么?我应该设置什么click_action值?
假设我想SecondActivity通过点击通知来打开。
android payload firebase firebase-cloud-messaging firebase-console
您知道我可以在哪里查看和管理 FCM 中的主题(排序或管理控制台)吗?
谢谢!
* 更新 * 使用 FCM 科尔多瓦插件 (FCMPlugin),我在我的应用程序中编写了以下内容:
FCMPlugin.getToken(function(token){
console.log('FCMPLUGIN: ', token);
alert(token); // the token pops up in my app
});
FCMPlugin.subscribeToTopic('topics/chats/' + currentUser.auth.uid);
Run Code Online (Sandbox Code Playgroud)
没有错误,一切似乎都正常,但是当我转到通知控制台时,我看不到我的主题:

我在一些文档中读到,向不存在的主题发送消息会创建它,所以我尝试通过 FCMPlugin ( https://cordova-plugin-fcm.appspot.com/ )的测试控制台,但我的主题中仍然没有主题控制台......知道我做错了什么吗?