我想将选项菜单的点颜色更改为白色.我试图为此添加图像但不起作用.这该怎么做?
menu xml:
<menu 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"
tools:context="com.example.siddhi.timetablelayout.Main2Activity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never"
android:icon="@drawable/ic_more_vert_white_48dp"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
谢谢.
我在recyclerview中显示联系人列表.我正在显示联系人资料图像,首先我从服务器加载这些图像,然后将这些图像存储在外部存储器中.
然后从外部存储装载图像.我可以看到加载的图像,但是当我滚动时,我可以看到一些图像一两秒然后它们消失了,我可以看到默认的图像图标.
public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactHolder> {
private List<Contact> contactList;
File myDir1;
private Activity mContext;
private Boolean fileExists;
private File file;
private static final int MY_PERMISSIONS_REQUEST_CALL= 20;
public ContactAdapter(Activity context, List<Contact> contactList) {
this.contactList = contactList;
this.mContext = context;
}
@Override
public ContactHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_layout,null);
ContactHolder mh = new ContactHolder(v);
return mh;
}
@Override
public void onBindViewHolder(final ContactHolder contactHolder, int i) {
final Contact contact = contactList.get(i);
// Log.e("Imagename",""+"http://xesoftwares.co.in/contactsapi/profile_images/85368a5bbd6cffba8a3aa202a80563a2.jpg");//+feedItem.getThumbnail());
Target target = …
Run Code Online (Sandbox Code Playgroud) 我有一个sqlite数据库,我在其中存储所有事件.我以日期格式存储StartTime
和EndTime
反对每个事件.
我有几天的片段和标签以及一个添加事件的活动.事件显示在另一个片段中.
现在,我想检查事件是否彼此重叠,并根据哪个应用程序应显示消息.
如何在用户保存事件时在添加的事件活动中显示消息.
我怎样才能做到这一点?
我尝试过这种方式,但仍然添加了相同的开始时间和结束时间的事件:
ImageButton imageButton = (ImageButton)findViewById(R.id.imgbtn_fab);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
eventTitle = title.getText().toString();
EventTableHelper db = new EventTableHelper(getApplication());
List<EventData> events;
events = db.getAllEvents();
for (EventData eventData : events) {
String datefrom = eventData.getFromDate();
String[] times = datefrom.substring(11, 16).split(":");
minutesFrom = Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
String dateTo = eventData.getToDate();
//times = dateTo.substring(11,16).split(":");
String[] times1 = dateTo.substring(11, 16).split(":");
minutesTo = Integer.parseInt(times1[0]) * 60 + Integer.parseInt(times1[1]);
}
if (eventTitle.length() …
Run Code Online (Sandbox Code Playgroud) 我想从一个活动向另一个活动发送一个对象的数组列表.我正在使用Parcelable扩展我的对象类,并使用intent onActivityResult传输列表.
但是列表在第二个活动中显示为null.
第一项活动:
public class PlanEventActivity extends AppCompatActivity implements TimePickerDialog.OnTimeSetListener,
DatePickerDialog.OnDateSetListener{
private boolean mHoursMode;
RelativeLayout chooseEvent,time,date;
EditText eventName;
TextView timeTextView,dateTextView,chooseEventText;
static final int CUSTOM_DIALOG_ID = 0;
ListView dialog_ListView;
private ImageView addOrganizer;
static final int PICK_CONTACT_REQUEST = 1;
private ArrayList<contact> mSelectedContacts;
private ListViewAdapter mAdapter;
private ListView mContactsList;
private ArrayList<Integer> selectedItemsPositions;
private boolean mContactListActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_plan_event);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("");
TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
toolbarTitle.setText("MeaVita");
setSupportActionBar(toolbar);
setUpUI();
mAdapter = new ListViewAdapter(this,mSelectedContacts);
mContactsList.setAdapter(mAdapter); …
Run Code Online (Sandbox Code Playgroud) 我想显示4种不同类型布局的通知列表.将有4种类型的通知chat_noti,share_noti,coorganizer_noti,invitation_noti.这4种类型有4种不同的布局.我想在recyclerview中展示这一点.
这是我的适配器:
编辑:
List<Notifications> notificationsList;
Context context;
private static final int INVITATION_NOTI = 0;
private static final int CHAT_NOTI = 1;
private static final int SHARE_NOTI = 2;
private static final int COORGANIZER_NOTI = 3;
private int selectedPos = 0;
public NotificationsAdapter(Context context,List<Notifications> notificationsList){
this.notificationsList = notificationsList;
this.context = context;
}
@Override
public int getItemViewType(int type) {
if (type == 0)
{
return INVITATION_NOTI;
}
else if(type == 1)
{
return CHAT_NOTI;
}
else if(type == 2)
{
return SHARE_NOTI; …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Android ViewModel 添加 Room 数据库。我按照此链接进行了相同的https://codelabs.developers.google.com/codelabs/android-room-with-a-view/#13
我遇到了一个例外:
导致:java.lang.RuntimeException:无法创建类 com.example.dailyfaithapp.ViewModels.FavouritesViewModel 的实例
我检查了一些问题和答案,但没有一个对我有用。
这是我的视图模型
public class FavouritesViewModel extends ViewModel {
public FavouriteRepository mRepository;
public LiveData<List<Favourites>> mAllFavourites;
public FavouritesViewModel (Application application) {
mRepository = new FavouriteRepository(application);
mAllFavourites = mRepository.getmAllFavourites();
}
public LiveData<List<Favourites>> getmAllFavourites() { return mAllFavourites; }
public void insert(Favourites favourites) { mRepository.insertFavourite(favourites); }
}
Run Code Online (Sandbox Code Playgroud)
我还尝试使用视图模型工厂调用视图模型,但在这里不起作用
public class FavouritesViewModelFactory implements ViewModelProvider.Factory {
private Application mApplication;
private String mParam;
public FavouritesViewModelFactory(Application application) {
mApplication = application;
}
@Override
public <T extends ViewModel> T …
Run Code Online (Sandbox Code Playgroud) 我想在指定的时间显示通知。就像我有一个开始时间,从我想要查看通知和结束时间到我想要查看通知,即应该在给定时间段中显示的字符串列表。
此外,列表可以是用户指定的任何数量。
如何决定动态显示通知的时间?或者如何统一划分时隙和字符串?
此处的更多说明是显示通知中显示的开始时间、结束时间和字符串计数的屏幕:
请帮忙。谢谢...
编辑 :
我正在尝试给定的解决方案。
List<String> times = new ArrayList<>();
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
Date start = dateFormat.parse(startTime);
Date end = dateFormat.parse(endTime);
long minutes = ((end.getTime() - start.getTime()) / 1000 / 60) /
howMany;
for (int i = 0; i < howMany; i++) {
Calendar calobj = Calendar.getInstance();
calobj.setTime(start);
calobj.add(Calendar.MINUTE, (int) (i * minutes));
String time = dateFormat.format(calobj.getTime());
times.add(time);
}
} catch (Exception e) {
e.printStackTrace();
}
Log.d("timesList", times.toString());
return times;
}
public …
Run Code Online (Sandbox Code Playgroud) I have an app which has fragment
and image button
on that. The problem is it's working on and above 5.0
but not below 5.0. The min sdk version is 17.
Not getting what's wrong here. I am getting 2 exceptions.
One is RuntimeException
for image button
.
Second is ResourceNotFoundException
for fab selector file.
Log : 1st exception --
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}: android.view.InflateException: Binary XML file line #16:
Error inflating class ImageButton
2nd exception --
Caused …
android android-resources inflate-exception binary-xml android-imagebutton
我想在我的两个相对布局之间有一个浮动动作按钮.
为此,我将父布局作为协调器布局,并将锚和锚重力指定为fab按钮.
但它没有被设定在我想要的地方.
我希望它设置在相对布局6的右下角,以及相对布局6和右角的相对布局3之间.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:background="@color/bg"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativeLayoutParent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/imageView5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="30dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginStart="30dp"
android:layout_marginTop="30dp"
android:background="@color/colorAccent">
<RelativeLayout
android:id="@+id/relativeLayout6"
android:layout_width="match_parent"
android:layout_height="240dp"
android:layout_centerHorizontal="true">
<ImageView
android:id="@+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
app:srcCompat="@drawable/profile_img" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/relativeLayout6">
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchorGravity="center"
app:layout_anchor = "@id/linearLayout"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</LinearLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
请帮忙..谢谢.
我想在切换项目时更改底部导航视图的图标。
我对所选项目有浅蓝色图标和深蓝色图标。我为每个导航项使用可绘制的选择器,但我看到像下面这样的图像,灰色为非活动状态,蓝色为活动状态
这是我的代码
底部导航菜单
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/home_icon_selector"
android:title="@string/title_home" />
<item
android:id="@+id/navigation_scheduler"
android:icon="@drawable/schelduler_icon_selector"
android:title="@string/title_scheduler" />
<item
android:id="@+id/navigation_favourites"
android:icon="@drawable/favourites_icon_selector"
android:title="@string/title_favourites" />
<item
android:id="@+id/navigation_settings"
android:icon="@drawable/settings_icon_selector"
android:title="@string/title_settings" />
</menu>
Run Code Online (Sandbox Code Playgroud)
家
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_20"
android:layout_marginLeft="@dimen/margin_20"
android:layout_marginRight="@dimen/margin_20"
android:layout_marginEnd="@dimen/margin_20"
android:layout_marginBottom="@dimen/margin_8"
android:background="@drawable/bottom_navigation_background"
android:elevation="8dp"
app:itemIconTint="@drawable/bottom_navigation_color_selector"
app:labelVisibilityMode="unlabeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
Run Code Online (Sandbox Code Playgroud)
和选择器
调度选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/qa_scheduler_inactive" android:state_checked="false"/>
<item android:drawable="@drawable/ic_scheduler_blue" android:state_checked="true"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
设置选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/qa_settings_inactive" android:state_checked="false"/>
<item android:drawable="@drawable/ic_settings_blue" android:state_checked="true"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
收藏夹选择器
<?xml version="1.0" encoding="utf-8"?> …
Run Code Online (Sandbox Code Playgroud) android android-icons kotlin android-drawable bottomnavigationview
android ×10
java ×7
alarmmanager ×1
android-mvvm ×1
arraylist ×1
binary-xml ×1
colors ×1
date ×1
image ×1
kotlin ×1
lazy-loading ×1
menu ×1
options ×1
overlap ×1
parcelable ×1
sqlite ×1