答案 0 :(得分:-1)
最简单的方法是使用 public class valance extends Fragment {
Button get, add;
ListView list;
SimpleAdapter ADAhere;
ProgressBar progressBar;
Connection connect;
String ConnectionResult = "";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_valance, container, false);
list = (ListView) rootView.findViewById(R.id.raill);
add = (Button) rootView.findViewById(R.id.btn_add);
progressBar = (ProgressBar) rootView.findViewById(R.id.PB_Getting);
progressBar.setVisibility(View.GONE);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getActivity(), Add_valance.class);
startActivity(i);
}
});
//Call to async
new GetValence().execute();
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
/** To change selected state view */
view.setSelected(true);
HashMap<String, Object> obj = (HashMap<String, Object>) ADAhere.getItem(position);
String SlectedName = (String) obj.get("NAME");
String SlectedPrice = (String) obj.get("PRICE");
String SlectedSize = (String) obj.get("SIZE");
String SlectedRange = (String) obj.get("RANGE");
String SlectedSupp = (String) obj.get("SUPPLIER");
// Toast.makeText(getActivity().getApplicationContext(), SlectedName, Toast.LENGTH_SHORT).show();
final Dialog dialog = new Dialog(getActivity());
dialog.getWindow();
//dialog.setTitle("Confirm your Vote");
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.diaglog);
final TextView VName = (TextView) dialog.findViewById(R.id.Name);
final TextView VRange = (TextView) dialog.findViewById(R.id.Range);
final TextView VSUPPLIER = (TextView) dialog.findViewById(R.id.Supplier);
final TextView VSIZE = (TextView) dialog.findViewById(R.id.Size);
final TextView VPrice = (TextView) dialog.findViewById(R.id.Price);
VName.setText(SlectedName);
VRange.setText(SlectedRange);
VSUPPLIER.setText(SlectedSupp);
VSIZE.setText(SlectedSize);
VPrice.setText(SlectedPrice);
dialog.show();
Button cancelBtn = (Button) dialog.findViewById(R.id.cancel_btn);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
dialog.show();
}
});
return rootView;
}
public class GetValence extends AsyncTask<String, Integer, List<Map<String, String>>> {
Connection connect;
String ConnectionResult = "";
Boolean isSuccess = false;
public List<Map<String, String>> doInBackground(String... params) {
List<Map<String, String>> data = null;
data = new ArrayList<>();
try {
ConnectionHelper conStr = new ConnectionHelper();
connect = conStr.connectionclass(); // Connect to database
if (connect == null) {
ConnectionResult = "Check Your Internet Access!";
} else {
// Change below query according to your own database.
String query = "select * from cc_valence";
Statement stmt = connect.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
Map<String, String> datanum = new HashMap<String, String>();
datanum.put("NAME", rs.getString("VALENCE_NAME"));
datanum.put("PRICE", rs.getString("VALENCE_UNIT_PRICE"));
datanum.put("RANGE", rs.getString("VALENCE_RANGE"));
datanum.put("SUPPLIER", rs.getString("VALENCE_SUPPLIER"));
datanum.put("SIZE", rs.getString("VALENCE_SIZE"));
data.add(datanum);
}
ConnectionResult = " successful";
isSuccess = true;
connect.close();
}
} catch (Exception ex) {
isSuccess = false;
ConnectionResult = ex.getMessage();
}
return data;
}
public void onPostExecute(List<Map<String, String>> result) {
String[] fromwhere = {"NAME", "PRICE", "SIZE", "RANGE", "SUPPLIER"};
int[] viewswhere = {R.id.Name_txtView, R.id.price_txtView, R.id.size_txtView};
ADAhere = new SimpleAdapter(getActivity(), result, R.layout.list_valence, fromwhere, viewswhere);
list.setAdapter(ADAhere);
}
}
}
:
return clients.filter(it =>
it.firstName.toLowerCase().includes(searchText) ||
it.lastName.toLowerCase().includes(searchText) ||
it.street.toLowerCase().includes(searchText) ||
it.city.toLowerCase().includes(searchText) ||
it.zipCode.toLowerCase().includes(searchText) ||
it.country.toLowerCase().includes(searchText) ||
it.email.toLowerCase().includes(searchText) ||
it.phone.toLowerCase().includes(searchText)
);
除非您要特定的结果,并且可以表达所需的输出,否则我不明白为什么旧的data.frame
不会削减它。
多面表:
data.frame(table(Medicine, choose, Period))
并将其包装在data.frame()
或xtabs(~cyl+gear+am, mtcars)
, , am = 0
gear
cyl 3 4 5
4 1 2 0
6 2 2 0
8 12 0 0
, , am = 1
gear
cyl 3 4 5
4 0 6 2
6 0 2 1
8 0 0 2
中:
data.frame()