大家好,我使用下面的代码获取Android手机时间,但如果分钟在1到9之间,它给我几分钟没有零.
例如:现在我有时间在我的设备12:09,但它给我12:9
Calendar c = Calendar.getInstance();
int hrs = c.get(Calendar.HOUR);
int mnts = c.get(Calendar.MINUTE);
String curTime = "" + hrs + ":" + mnts;
return curTime;
Run Code Online (Sandbox Code Playgroud)
在上面的代码之后,我也尝试下面的代码,它给出与上面相同的东西,分钟没有零,然后编号在1到9之间的分钟..
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
Date date = cal.getTime();
int mHour = date.getHours();
int mMinute = date.getMinutes();
Run Code Online (Sandbox Code Playgroud) 我想在android中使用SQLite访问记录rawQuery(query,arg).我在数据库中有两列被调用friendsID,第二列被调用emailSenderID.
现在,如果我发送邮件给我的朋友 - emailSenderID列将保存我的ID和friendsID-column保存我朋友的ID.如果我收到来自同一个朋友的电子邮件,那么friendsID-column将保存我的ID,emailSenderID-column将保存我朋友的ID.
现在,如果我想获取这样的记录:
Select * from emailTable where friendsID =fID
and emailSenderID=fID
OR emailSenderID=myID
Run Code Online (Sandbox Code Playgroud)
请指导我如何使用Android SQLite AND和OR操作符.
我正在尝试创建一个带有一些文本的聊天气泡.为此我创建了三个布局,在主线性布局内部我正在使用FramLayout,我正在设置一个9补丁背景到这个Framlayout.Inside的Framlayout我正在添加一个RelativeLayout我放置我的三个textViews和一个imageView.but键入长文本它走出FramLayout边界.我不知道我做错了什么或我缺少什么.当我使用小文本它仍然适合,但与大文本它甚至从FramLayout的背景边框出去.在附件我显示我的泡沫和雅虎IM泡沫.我正在尝试创建像雅虎但有一些不同的风格.请给我你的建议.我尝试了很多与不同方法,但没有获得成功.谢谢你提前..
在这里我放置我的布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/linearListLayout1">
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bubbleblue" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minHeight="100dp">
<TextView
android:id="@+id/chattitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"/>
<TextView android:id="@+id/chatdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"/>
<TextView android:id="@+id/chatText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/chatstatus"
android:layout_below="@+id/chattitle"
android:layout_toLeftOf="@+id/chatstatus"
android:text="TextView" />
<ImageView
android:id="@+id/chatstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/add_picture"
android:layout_alignParentRight="true"
android:layout_below="@+id/chatdate"
android:minHeight="2dip"
android:maxWidth="2sp"
android:maxHeight="2sp"
android:layout_marginRight="2dp"/>
</RelativeLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我使用下面的代码来绕过RelativeLayout的角.我把它保存mybackground.xml在drawable文件夹中.
它可以很好地圆角,但问题是我还想添加透明图像作为我的RelativeLayout的背景.我怎样才能实现这两件事?如何为RelativeLayout同时使用图像和可绘制的xml(用于圆角)...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<corners android:bottomRightRadius="30dp"
android:bottomLeftRadius="30dp"
android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
</shape>
Run Code Online (Sandbox Code Playgroud) 我正在使用asmack作为一个Android IM应用程序,我正在使用AIDL接口的远程服务.
在onStartCommand我的服务方法内部,我编写如下代码.我创建连接,然后使用它登录.当任何人在我的应用程序onCreate的主要活动方法中运行我的应用程序运行我的服务getApplicationContext.StartService(serviceIntent).它工作正常,但是messageListener我在服务内部附加的几分钟(有时10分钟,一些时间超过10分钟)停止接收消息.但我知道连接存在,因为同时我用xmppConnection它来发送消息它正在向用户B发送消息但是它没有收听来自用户B的消息.我不知道为什么我的听众停止听到消息.
public int onStartCommand(final Intent intent, final int flags, final int startId) {
ConnectionConfiguration config = new ConnectionConfiguration(URL, MyPort, Host);
xmppConnection = new XMPPConnection(config);
xmppConnection.connect();
xmppConnection.login("someid@sample.com", "testpass");
xmppConnection.addPacketListener(myMessageListener, new PacketTypeFilter(Message.class));
return START_STICKY;
}
private PacketListener myMessageListener = new PacketListener() {
public void processPacket(Packet packet) {
Message msg = (Message) packet;
}
}
Run Code Online (Sandbox Code Playgroud)
请指导.
大家好我正在使用此代码将文本附加到txt文件中.任何人都可以指导我如何为此案例添加换行符
fOut = new FileOutputStream(new File(myFilePath + BlueFreeConstants.logFileName), true);
osw = new OutputStreamWriter(fOut);
osw.append("<< " + values + " >>");
osw.flush();
osw.close();
fOut.close();
Run Code Online (Sandbox Code Playgroud) 大家好用三星Galaxy GT-1900,在eclipse中我试图访问我的应用程序的DDMS文件浏览器视图中的数据文件夹,其数据文件夹可见但无法打开,面临同样的问题,如此处发布无法访问数据文件夹中使用Nexus One的DDMS文件浏览器!我点击加号数据文件夹,如果消失为2-6.我尝试探索数据文件夹与正常和调试模式.无法访问此文件夹.当我在模拟器上运行我的应用程序,它在模拟器中工作正常我可以访问数据DDMS文件浏览器视图中的文件夹.任何适合的答案如何访问此文件夹以导出/浏览我的数据库和txt文件.我正在附加我的DDMS视图..

我正在尝试使用下面的代码连接php-MySQL
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://127.0.0.1/mytable.php");
// HttpPost httppost = new HttpPost("http://localhost/mytable.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
Run Code Online (Sandbox Code Playgroud)
当控件继续httpclient.execute(httppost);时抛出异常:
org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1 refused
Run Code Online (Sandbox Code Playgroud)
我还添加<uses-permission android:name="android.permission.INTERNET" />到我的AndroidManifest.xml文件中.
当我直接从浏览器测试我的PHP文件时,它工作正常.有什么建议?