Android Studio中新的默认导航抽屉活动模板
在菜单文件中定义其标题和图标,activity_main_drawer如下所示:
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_camara"
android:icon="@drawable/ic_action_emo_cool"
android:title="Import" />
<item
android:id="@+id/nav_gallery"
android:icon="@android:drawable/ic_menu_gallery"
android:title="Gallery" />
<item
android:id="@+id/nav_slideshow"
android:icon="@android:drawable/ic_menu_slideshow"
android:title="Slideshow" />
...
Run Code Online (Sandbox Code Playgroud)
我的示例中的第一项使用了一个红色图标:
但是当我运行应用程序时,图标的颜色仍然是黑色.我已经测试了这个蓝色,绿色,黄色和紫色图标,但结果是一样的.
我读到工具栏应该使用的地方,ThemeOverlay.AppCompat.Dark.ActionBar我的应用程序已在styles.xml文件中使用它:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Run Code Online (Sandbox Code Playgroud)
最初我认为这与Android Studio的缓存功能有关,所以我使缓存失效并重新启动Android Studio而没有运气.
我能够打印文本,但是当涉及条形码时,它始终不显示或仅显示数字参数
这是我的源代码
//barcode 128
byte[] formats = {(byte) 0x1d, (byte) 0x6b, (byte) 0x73,(byte) 0x0d};
byte[] contents = content.getBytes();
byte[] bytes = new byte[formats.length + contents.length];
System.arraycopy(formats, 0, bytes, 0, formats.length );
System.arraycopy(contents, 0, bytes, formats.length, contents.length);
usbCtrl.sendByte(bytes, dev);
usbCtrl.sendByte(LineFeed(), dev);
Run Code Online (Sandbox Code Playgroud)
但结果条形码没有显示,我错过了什么
请帮我
编辑
我找到了ESC/POS代码:
GS km d1 ... dk NUL或GS kmn d1 ... dk
但仍然没有工作
我有时间以下格式
2015-10-28T18:37:04.899 + 05:30
我必须以下面的格式创建插槽
上午11点至下午12点
2015年10月28日下午12点至下午1点
下午1点至2点28分
String timeValue = "2015-10-28T18:37:04.899+05:30";
StringTokenizer stringTokenizer = new StringTokenizer(timeValue,"T");
String dateValue = stringTokenizer.nextElement().toString();
String endDateValue = "2015-10-30";
String restString= stringTokenizer.nextElement().toString();
StringTokenizer secondTokeniser = new StringTokenizer(restString,":");
String hours = secondTokeniser.nextElement().toString();
String minutes = secondTokeniser.nextElement().toString();
hours = String.valueOf(Integer.parseInt(hours) + 2);
if (Integer.parseInt(minutes) > 30){
minutes = "00";
}else{
minutes = "30";
}
String amOrPm = null;
if(Integer.parseInt(hours) < 12){
amOrPm = "AM";
}else{
amOrPm = "PM";
hours = String.valueOf(getHoursValue(Integer.parseInt(hours)));
}
String time1 = hours …Run Code Online (Sandbox Code Playgroud) 我想要一个 recyclerview 布局管理器,其工作方式类似于具有两列的 GridlayoutManager,但先填充第一列,然后再将项目添加到第二列。或者更确切地说,将剩余的项目添加到第二列。有什么建议么?
在我的应用程序中,我想将填充应用于主题的所有屏幕顶级容器。
例如:
这是布局文件。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".MainActivity">
<EditText
android:id="@+id/edt"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是应用程序主题。
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowFrame">@drawable/window_frame</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我可以android:padding对父容器RelativeLayout 使用padding 。但是我不想这样,因为我需要在每个布局文件中指定相同的内容,我想在主题-AppTheme中进行定义。
任何解决方案将不胜感激。
我有一个问题,当我的连接中断时,重新连接时 mqtt 发布不发送,如何解决?我正在关注这个答案但不起作用
我所做的:
但是当我重新连接时的结果仍然是在我在线时发布数据而不是发布存储的持久性数据。
这是我的源代码:
package id.trustudio.android.mdm.service;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.TrafficStats;
import android.os.Handler;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;
import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import java.io.UnsupportedEncodingException;
import id.trustudio.android.mdm.http.DetectConnection;
import id.trustudio.android.mdm.util.Cons;
import id.trustudio.android.mdm.util.Debug;
import …Run Code Online (Sandbox Code Playgroud) 我从github获得了一个名为android-async-http-master的android项目,这是下载链接:https://github.com/loopj/android-async-http 但是当我将项目导入到eclipse时,它有一个错误.
我得到这样的错误:
import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HeaderElement;
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:项目包名是com.loopj.android.http,is the cz.msebera.android.httpclient包哪里?
我正在尝试构建android studio项目,并且我遇到以下错误:
Error:(11, 28) No resource found that matches the given name (at 'minHeight' with value '?attr/actionBarSize').
Error:(12, 29) No resource found that matches the given name (at 'background' with value '?attr/colorPrimary').
Run Code Online (Sandbox Code Playgroud)
下面是我的XML文件: -
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:qwerjk="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black" >
<android.support.v7.widget.Toolbar
android:id="@+id/builder_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/layout_bottom"
android:layout_below="@id/builder_toolbar"
android:layout_centerInParent="true" >
<RelativeLayout
android:id="@+id/lCanvas"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<ImageView
android:id="@+id/imgEditor"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true" />
<qwerjk.better_text.MagicTextView
android:id="@+id/tvEditTop"
style="@style/BuilderText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/imgEditor"
android:layout_centerHorizontal="true"
android:text="TOP"
qwerjk:strokeColor="#FF000000"
qwerjk:strokeJoinStyle="miter"
qwerjk:strokeWidth="5" …Run Code Online (Sandbox Code Playgroud) 如何获得我的颜色并将其设置为不透明?
int myColor = getResources().getColor(R.color.ColorPrimary);
Run Code Online (Sandbox Code Playgroud) android ×9
asynchronous ×1
build.gradle ×1
date ×1
datetime ×1
github ×1
java ×1
mqtt ×1
printing ×1