如何将'timeStamp'转换为datejava后的计数?
我目前的代码如下:
public class GetCurrentDateTime {
public int data() {
int count = 0;
java.sql.Timestamp timeStamp = new Timestamp(System.currentTimeMillis());
java.sql.Date date = new java.sql.Date(timeStamp.getTime());
System.out.println(date);
//count++;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro", "root", "");
PreparedStatement statement = con.prepareStatement("select * from orders where status='Q' AND date=CURDATE()");
ResultSet result = statement.executeQuery();
while (result.next()) {
// Do something with the row returned.
count++; //if the first col is a count.
}
} catch (Exception exc) {
System.out.println(exc.getMessage());
}
return count; …Run Code Online (Sandbox Code Playgroud) 我有验证editText.如果该editText字段为空,则应验证失败并停止用户移动到另一个Activity,因为需要值.怎么做?我知道这是一个基本问题,但我无法弄清楚如何做到这一点.
我的代码:
btninsert = (Button)findViewById(R.id.btn_insert);
btninsert.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
insertValues();
EditText userName = (EditText) findViewById(R.id.editText1);
if( userName.getText().toString().length() == 0 )
userName.setError( "First name is required!" );
Intent i = new Intent(getApplicationContext(), Login.class);
startActivity(i);
}
});
Run Code Online (Sandbox Code Playgroud)
Button 单击此按钮时,用户将重定向到下一个屏幕,但是如果验证失败,我需要保持当前状态Activity,并且只有在验证成功时(即已输入值),他们才会转到下一个屏幕Activity.
我必须在我的应用程序中实现Paypal.在这里,我已经将一些产品添加到购物车中.如果我点击购物车,我必须使用Paypal支付金额.
单击Paypal按钮时,我收到以下错误:
为物料价格,税金和运输指定的金额不等于总金额.
为什么会收到此错误?
我使用以下代码:
$.paypalWindow.addEventListener('open', function(){
var Paypal = require('ti.paypal');
var u = Ti.Android != undefined ? 'dp' : 0;
var status = Ti.UI.createLabel({ top: 20 + u, height: 50 + u, color: '#333', text: 'Loading, please wait...' });
$.paypalWindow.add(status); var price = totalamount;
var invoiceitemslist = JSON.stringify(data);
var button; function addButtonToWindow() {
if (button) { $.paypalWindow.remove(button); button = null; }
button = Paypal.createPaypalButton({ width: 194 + u, height: 37 + u, buttonStyle: Paypal.BUTTON_194x37, top: 20 + u,
language: …Run Code Online (Sandbox Code Playgroud) 我开发了一个基于以下树结构的应用程序:
默认值:
点击类别时:
类别
类别
有时候:
类别
类别
类别
在这里,我必须使用tableview实现这个概念.
是的我创建了tableview,然后我创建了tableviewsection.我已经在tableviewsection中添加了类别.我已经在tableviewsection中创建了tableviewrow.如果我单击所选类别,我已在这些tableviewrow中添加了子类别值.但是某些类别有子类别......某些类别没有子类别.直接有产品.所以请你解释一下我
编辑:
我有以下代码:
// create menu view
var data = [];
var v1 = Ti.UI.createView({
height: '100%',
width: '320dp',
left: '0%',
backgroundColor: '#212429'
});
$.drawermenu.drawermenuview.add(v1);
var tableView = Ti.UI.createTableView({
height: '100%',
width: '100%',
separatorColor: '#111214',
allowsSelection: true,
style: Ti.UI.iPhone.TableViewStyle.GROUPED
});
v1.add(tableView);
var dataArray = [];
getCategoryList();
function getCategoryList() {
var sendit = Ti.Network.createHTTPClient({
onerror: function(e) {
Ti.API.debug(e.error);
alert('There was an error during the …Run Code Online (Sandbox Code Playgroud) 我成功开发了一个登录表单.但是现在我无法管理会话...我也读过更多的会话概念.但我不能这样做.请详细解释我.这是我的代码.请帮助我在这里使用Session部分.
这是我的编码部分:
package com.androidlogin.ws;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class AndroidLoginExampleActivity extends Activity {
private final String NAMESPACE = "http://ws.userlogin.com";
private final String URL = "http://111.223.128.10:8085/AndroidLogin/services/Login?wsdl";
private final String SOAP_ACTION = "http://ws.userlogin.com/authentication";
private final String METHOD_NAME = "authentication";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button login = (Button) findViewById(R.id.btn_login); …Run Code Online (Sandbox Code Playgroud) 我试图使用titanium更新/更改android中的lebel.但是文本中没有显示该值.但是我在alert中获得了更新的值.但是ios工作正常.
var itemcounttext = Ti.UI.createLabel({
top: 5,
color: "#000000",
left:10,
text:data[i].itemCount,
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
});
var additem = Ti.UI.createImageView({
image: "/images/plus.jpg",
top: 5,
width: Ti.UI.SIZE,
left:10,
height: Ti.UI.SIZE,
});
adddeleteitemview.add(additem);
additem.addEventListener('click', function(e)
{
var item=e.source.getParent();
squantity = e.source.squantity;
squantity = Number(squantity) + 1;
item.children[1].text = squantity;
alert(item.children[1].getText());
Run Code Online (Sandbox Code Playgroud)
这里正在获取具有正确更新值的警报.但它没有显示在标签中.你能给我一个想法来解决android中的这个问题.
编辑:
从VRK评论我也试过了.但它没有工作.但我正确地得到警报.
item.children[1].setText(squantity);
Run Code Online (Sandbox Code Playgroud)
编辑:
我尝试用jsplaine回答.但我无法得到解决方案.在这里我创建了tableview.在这个tableview行中我们创建了view.in该视图我已经添加了additem,itemcounttext值.如果我们点击additem意味着需要更改itemcounttext值.这是一个流程.
如下面的截图是我的app tableview的子视图:
productname
remove itemcount add
image text image
Run Code Online (Sandbox Code Playgroud)
这三个图像,文本,图像值都添加到一个视图中.这就是为什么在单击添加图像时添加用于获取父视图的代码:
var item=e.source.getParent();
Run Code Online (Sandbox Code Playgroud)
这里得到了parent.also我写了下面的代码来获取这个视图的标签:
item.children[1].text
Run Code Online (Sandbox Code Playgroud)
如果单击添加图像,则正确地将标签值增加1.使用此代码验证.am alert(item.children[1].getText()); 但是没有显示更新的值.这是我的确切怀疑.
编辑:
这是我的完整源代码.
dataArray = [];
$.ViewCartItemslist_total_value.text = totalamount; …Run Code Online (Sandbox Code Playgroud) 我使用小部件开发了gridview应用程序(来自此代码)
https://github.com/pablorr18/TiDynamicGrid
我根据客户要求修改了代码.现在,如果我想点击列表项上的查看购物车按钮,它将提醒消息,如"被点击".但我尝试了各种方式.但我找不到解决方案.任何人都可以请解释我们如何为此编写代码.
我在我的应用程序中遵循以下代码:
var items = [];
var showGridItemInfo = function(e){
alert("Onclick the row");
};
var delay = (OS_ANDROID) ? 1000:500;
$.tdg.init({
columns:3,
space:5,
delayTime:delay,
gridBackgroundColor:'#e1e1e1',
itemBackgroundColor:'#fff',
itemBorderColor:'transparent',
itemBorderWidth:0,
itemBorderRadius:5,
onItemClick: showGridItemInfo
});
function createSampleData(){
var sendit = Ti.Network.createHTTPClient({
onerror: function(e){
Ti.API.debug(e.error);
alert('There was an error during the connection');
},
timeout:10000,
});
sendit.open('GET', url+'android_livedev/client/test.php?action=listitems&categoryid='+subcategorylist_category_id+'&productmin=0&productmax=50');
sendit.send();
sendit.onload = function(){
var response = JSON.parse(this.responseText);
if(response[0].success == 0){
alert("No Products Found");
}
else {
items = [];
for (var x=0;x<response[0].data.length;x++){
var view …Run Code Online (Sandbox Code Playgroud) 我在微调框中有7个项目.我创建了带有textview和复选框的微调框.我想做以下逻辑.
能否请你给我任何建议:
private static final String[] select_qualification = {
"Select Qualification", "10th / Below", "12th", "Diploma", "UG",
"PG", "Phd" };
Run Code Online (Sandbox Code Playgroud)
如果我将检查UG复选框,它会自动选中状态的复选框10th/Below,12th,Diploma还取消复选框的选中状态PG和phd.
如果选中任何复选框,则表示上一项复选框自动需要选中状态,下一项复选框自动需要取消选中状态.
现在这是我的适配器文件:
public class CustomAdapter extends ArrayAdapter<String> {
public CustomAdapter(Context context, int resourceId, String[] objects) {
super(context, resourceId, objects);
// TODO Auto-generated constructor stub
}
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) …Run Code Online (Sandbox Code Playgroud) checkbox android custom-adapter android-spinner android-activity
我已经在我的android应用程序中通过soap webservices使用MySQL连接开发了一个登录表单(用户名,密码和提交按钮).我希望添加一个"记住密码字段".我已在活动的XML资源中编写此代码:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/tf_userName"
android:layout_width="194dp"
android:layout_height="wrap_content"
android:layout_x="106dp"
android:layout_y="80dp" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="23dp"
android:layout_y="93dp"
android:text="User name" />
<EditText
android:id="@+id/tf_password"
android:layout_width="189dp"
android:layout_height="wrap_content"
android:layout_x="108dp"
android:layout_y="161dp"
android:inputType="textPassword" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="23dp"
android:layout_y="176dp"
android:text="Password" />
<CheckBox android:layout_below="@+id/passwordview"
android:layout_width="wrap_content" android:text="Remember Password!"
android:layout_height="wrap_content" android:id="@+id/rempasswordcheckbox"
android:layout_x="23dp"
android:layout_y="200dp" />
<Button
android:id="@+id/btn_login"
android:layout_width="106dp"
android:layout_height="wrap_content"
android:layout_x="50dp"
android:layout_y="273dp"
android:text="Login" />
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="50dp"
android:layout_y="350dp"
android:text="Forget My password ?: Click here" />
<Button
android:id="@+id/btn_reg"
android:layout_width="106dp" …Run Code Online (Sandbox Code Playgroud) 我有一个数据库 - 亲.表名是订单.该表有一个字段 - 总计.总数有 - (100,200,300,400,500).现在我需要添加上面数据库中的所有值.我怎么能用Java做到这一点?如何用Java编写查询?请帮我.这是我的代码部分:
public class GetCurrentDateTime {
private Object sum;
public int data(){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro","root","");
PreparedStatement statement = con.prepareStatement("select sum(total) from orders where status='Q' AND WEEK(date) = WEEK(CURDATE()) AND YEAR(date) = YEAR(CURDATE())");
ResultSet result = statement.executeQuery();
println(result,getString(1));
}
catch(Exception exc){
System.out.println(exc.getMessage());
}
return 0;
}
private void println(ResultSet result, Object string) {
// TODO Auto-generated method stub
}
private Object getString(int i) {
// TODO Auto-generated method …Run Code Online (Sandbox Code Playgroud)