我正在申请,但我被困了。我不确定如何获取列的总和并将值放入<DataGrid.CellStyle>
<Style TargetType="{x:Type wpf:DataGridCell}">
<Setter Property="Background" Value="{Binding SomeColorProperty, Converter={StaticResource cellBackgroundConverter}}" />
<Setter Property="FontWeight" Value="{Binding SomeWeightProperty, Converter={StaticResource cellWeightConverter}}" />
.....
</Style>
</DataGrid.CellStyle>
。我还想在长按列表项时删除项目。我知道如何使用长按,但我不知道如何在项目被迫按下时获取该列表项名称或ID。这是我的TextView
课程:
DbOperation.java
这是我的package com.wavedevelopers.databaseasynctaskdemo;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
/**
* Created by Haider885 on 25/08/2016.
*/
public class DbOperation extends SQLiteOpenHelper {
private static final int DB_VERSION = 1;
private static final String DB_NAME = "ProductInfo1.db";
private static final String CREATE_QUERY = "CREATE TABLE " + ProductContract.ProductEntry.TABLE_NAME +
"( "+ ProductContract.ProductEntry.ID + " TEXT, " + ProductContract.ProductEntry.NAME + " TEXT, " +
ProductContract.ProductEntry.PRICE + " FLOAT, " + ProductContract.ProductEntry.QTY + " FLOAT, "+ ProductContract.ProductEntry.TOTAL + " FLOAT );";
public DbOperation(Context context) {
super(context, DB_NAME, null, DB_VERSION);
Log.d("Database Opeation","Database Created...");
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL(CREATE_QUERY);
Log.d("Database Opeation","Table Created...");
}
public void addProduct(SQLiteDatabase DB, String id, String name, float price, float qty,float total)
{
ContentValues contentValues = new ContentValues();
contentValues.put(ProductContract.ProductEntry.ID,id);
contentValues.put(ProductContract.ProductEntry.NAME,name);
contentValues.put(ProductContract.ProductEntry.PRICE,price);
contentValues.put(ProductContract.ProductEntry.QTY,qty);
contentValues.put(ProductContract.ProductEntry.TOTAL,total);
DB.insert(ProductContract.ProductEntry.TABLE_NAME,null,contentValues);
Log.d("Database Opeation","One Row Inserted...");
}
public Cursor getInformation(SQLiteDatabase db)
{
String[] projections = {ProductContract.ProductEntry.ID, ProductContract.ProductEntry.NAME, ProductContract.ProductEntry.PRICE, ProductContract.ProductEntry.QTY, ProductContract.ProductEntry.TOTAL};
Cursor cursor = db.query(ProductContract.ProductEntry.TABLE_NAME,projections,null,null,null,null,null);
return cursor;
}
public String getGrandTotal(SQLiteDatabase db)
{
String total = null;
String[] projections = {ProductContract.ProductEntry.ID, ProductContract.ProductEntry.NAME, ProductContract.ProductEntry.PRICE, ProductContract.ProductEntry.QTY, ProductContract.ProductEntry.TOTAL};
db.execSQL("SELECT SUM("+ ProductContract.ProductEntry.TOTAL +") FROM " + ProductContract.ProductEntry.TABLE_NAME + ";");
db.close();
return total;
}
public void deleteContact(Product product) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(ProductContract.ProductEntry.TABLE_NAME, ProductContract.ProductEntry.ID + " = ?",
new String[] { String.valueOf(product.getId()) });
db.close();
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
}
课程:
BackgroundTask.java
有关如何实现这一目标的任何建议吗?