我试图实现一种方式,其中"客户端"可以申请我发布的某些工作。
我得到了显示器和数据库,我现在要做的是创建一个按钮,在按下“提交”按钮后,自动发送一封包含客户选择的作业的电子邮件。
该应用程序还具有登录功能:名称,电子邮件和电话号码
我的问题是:如何使用客户名称(我从数据库中获取)发送电子邮件,并在同一邮件中包含他选择的作业名称?
这是我到目前为止所做的:
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
db = (new DBResep(this)).getWritableDatabase();
lv = (ListView) findViewById(R.id.lv);
et_db = (AutoCompleteTextView) findViewById(R.id.et);
et_db2 = (AutoCompleteTextView) findViewById(R.id.et2);
try {
cursor = db.rawQuery("SELECT * FROM resep ORDER BY name ASC", null);
adapter = new SimpleCursorAdapter(this, R.layout.isi_lv, cursor,
new String[]{"name", "oras", "img"}, new int[]{
R.id.tv_name, R.id.tvOras, R.id.imV});
lv.setAdapter(adapter);
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
detail(position);
}
});
} catch (Exception e) {
e.printStackTrace();
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this, android.R.layout.select_dialog_item, arr);
//Getting the instance of AutoCompleteTextView
AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.et2);
actv.setThreshold(0);//will start working from first character
actv.setAdapter(adapter);//setting the adapter data into the AutoCompleteTextView
ArrayAdapter<String> adapter2 = new ArrayAdapter<String>
(this, android.R.layout.select_dialog_item, arr2);
//Getting the instance of AutoCompleteTextView
AutoCompleteTextView actv2 = (AutoCompleteTextView) findViewById(R.id.et);
actv2.setThreshold(0);//will start working from first character
actv2.setAdapter(adapter2);//setting the adapter data into the AutoCompleteTextView
}
@SuppressWarnings("deprecation")
public void search_db(View v) {
String edit_db = et_db.getText().toString();
if (!edit_db.equals("")) {
try {
cursor = db.rawQuery("SELECT * FROM resep WHERE tara LIKE ?",
new String[] { "%" + edit_db + "%" });
adapter = new SimpleCursorAdapter(
this,
R.layout.isi_lv,
cursor,
new String[] { "name", "oras", "img" },
new int[] { R.id.tv_name, R.id.tvOras, R.id.imV });
if (adapter.getCount() == 0) {
Toast.makeText(
this,
"We couldn't find any project in that country " + edit_db
+ "", Toast.LENGTH_SHORT).show();
} else {
lv.setAdapter(adapter);
}
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
cursor = db.rawQuery("SELECT * FROM resep ORDER BY name ASC",
null);
adapter = new SimpleCursorAdapter(
this,
R.layout.isi_lv,
cursor,
new String[] { "name", "oras", "img" },
new int[] { R.id.tv_name, R.id.tvOras, R.id.imV });
lv.setAdapter(adapter);
lv.setTextFilterEnabled(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@SuppressWarnings("deprecation")
public void search_db2(View v) {
String edit_db = et_db2.getText().toString();
if (!edit_db.equals("")) {
try {
cursor = db.rawQuery("SELECT * FROM resep WHERE luna LIKE ?",
new String[] { "%" + edit_db + "%" });
adapter = new SimpleCursorAdapter(
this,
R.layout.isi_lv,
cursor,
new String[] { "name", "oras", "img" },
new int[] { R.id.tv_name, R.id.tvOras, R.id.imV });
if (adapter.getCount() == 0) {
Toast.makeText(
this,
"We couldn't find any project in " + edit_db
+ "", Toast.LENGTH_SHORT).show();
} else {
lv.setAdapter(adapter);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void detail(int position) {
int im = 0;
String _id = "";
String name = "";
String oras = "";
String desc = "";
String durata = "";
String facil = "";
if (cursor.moveToFirst()) {
cursor.moveToPosition(position);
im = cursor.getInt(cursor.getColumnIndex("img"));
name = cursor.getString(cursor.getColumnIndex("name"));
oras = cursor.getString(cursor.getColumnIndex("oras"));
desc = cursor.getString(cursor.getColumnIndex("desc"));
durata = cursor.getString(cursor.getColumnIndex("durata"));
facil = cursor.getString(cursor.getColumnIndex("facil"));
}
Intent iIntent = new Intent(this, DB_Parse.class);
iIntent.putExtra("dataIM", im);
iIntent.putExtra("dataName", name);
iIntent.putExtra("dataoras", oras);
iIntent.putExtra("datadesc", desc);
iIntent.putExtra("dataDurata", durata);
iIntent.putExtra("dataFacil", facil);
setResult(RESULT_OK, iIntent);
startActivityForResult(iIntent, 99);
}
}