- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在从 SQL Server 检索数据时创建了一个异步任务像这样
private class MyAsyncTask extends AsyncTask<String, Void, String> {
protected void onPreExecute() {
// Runs on the UI thread before doInBackground
// Good for toggling visibility of a progress indicator
progressBar.setVisibility(ProgressBar.VISIBLE);
}
protected String doInBackground(String... strings) {
String someBitmap ="";
String menuListSTR = "";
if (MenuActivity.Prst_ID.trim() == "-1")
menuListSTR = "Select ID,Code,Name,Name2 From Presets Where Active = 1 And Rest_ID_Active = 1 AND OutLet_ID_Active = 1 ORDER BY Code";
else
menuListSTR = "select dbo.MenuItems.Item_ID, dbo.Items.Code, dbo.Items.Name, dbo.Items.Name2, dbo.Items.PrintOnChick, dbo.Items.Taxable, dbo.Items.NoServiceCharge, dbo.Items.PrintOnReport,Case { fn IFNULL ((SELECT Price_Value FROM dbo.ItemsPrices WHERE (PriceLVL_ID = 1) AND (Item_ID = dbo.Items.ID)), 0) } when 0 then dbo.Items.StaticPrice Else { fn IFNULL ((SELECT Price_Value FROM dbo.ItemsPrices WHERE (PriceLVL_ID = 1) AND (Item_ID = dbo.Items.ID)), dbo.Items.StaticPrice) } END AS Price From dbo.MenuItems LEFT OUTER JOIN dbo.Items ON dbo.MenuItems.Item_ID = dbo.Items.ID Where (dbo.MenuItems.Preset_ID = " + MenuActivity.Prst_ID + ") AND (dbo.MenuItems.Rest_ID_Active = " + ConnectionClass.Rest_ID + ") AND (dbo.MenuItems.OutLet_ID_Active = " + ConnectionClass.OutletID + ") AND (dbo.Items.Active = 1) ORDER BY dbo.MenuItems.SortNumber";
ResultSet rs = ConnectionClass.Ret_RS(menuListSTR);
try {
while (rs.next()) {
SortedMap<String, String> sm = new TreeMap<String, String>();
sm.put("Item_ID", rs.getString("Item_ID"));
sm.put("Name", rs.getString("Name"));
sm.put("Price", rs.getString("Price"));
sm.put("PrintOnChick", rs.getString("PrintOnChick"));
sm.put("Taxable", rs.getString("Taxable"));
sm.put("NoServiceCharge", rs.getString("NoServiceCharge"));
sm.put("PrintOnReport", rs.getString("PrintOnReport"));
if (TablesFragment.Check_Items.containsKey(rs.getString("Item_ID"))) {
SortedMap<String, String> sm1 = TablesFragment.Check_Items.get(rs.getString("Item_ID"));
sm.put("Qty", sm1.get("Qty"));
} else
sm.put("Qty", "0");
alphabets.add(sm);
listMenuArray.add(rs.getString("Name"));
}
} catch (SQLException e) {
e.printStackTrace();
}
return someBitmap;
}
// protected void onProgressUpdate(Progress... values) {
// // Executes whenever publishProgress is called from doInBackground
// // Used to update the progress indicator
// progressBar.setProgress(values[0]);
// }
protected void onPostExecute(Bitmap result) {
// This method is executed in the UIThread
// with access to the result of the long running task
menuListView.setAdapter(new CustomMenuLVAdapter(this, listMenuArray, alphabets));
// Hide the progress bar
progressBar.setVisibility(ProgressBar.INVISIBLE);
}
}
我收到了这样的带下划线的错误 这是我的 fragment ,我在上面放置了一个异步任务方法
package abtech.waiteriano.com.waitrer.fragments;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.ProgressBar;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.SortedMap;
import java.util.TreeMap;
import abtech.waiteriano.com.waitrer.MenuActivity;
import abtech.waiteriano.com.waitrer.R;
import abtech.waiteriano.com.waitrer.adapters.CustomMenuLVAdapter;
import abtech.waiteriano.com.waitrer.connection_class.ConnectionClass;
public class LVMenuFragment extends android.app.Fragment {
View rootView;
ListView menuListView;
public static ArrayList<String> listMenuArray = new ArrayList<String>();
ArrayList<SortedMap> alphabets = new ArrayList<SortedMap>();
public LVMenuFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
rootView = inflater.inflate(R.layout.fragment_lvmenu, container, false);
menuListView = (ListView) rootView.findViewById(R.id.listView);
listMenuArray.clear();
alphabets.clear();
String menuListSTR = "";
if (MenuActivity.Prst_ID.trim() == "-1")
menuListSTR = "Select ID,Code,Name,Name2 From Presets Where Active = 1 And Rest_ID_Active = 1 AND OutLet_ID_Active = 1 ORDER BY Code";
else
menuListSTR = "select dbo.MenuItems.Item_ID, dbo.Items.Code, dbo.Items.Name, dbo.Items.Name2, dbo.Items.PrintOnChick, dbo.Items.Taxable, dbo.Items.NoServiceCharge, dbo.Items.PrintOnReport,Case { fn IFNULL ((SELECT Price_Value FROM dbo.ItemsPrices WHERE (PriceLVL_ID = 1) AND (Item_ID = dbo.Items.ID)), 0) } when 0 then dbo.Items.StaticPrice Else { fn IFNULL ((SELECT Price_Value FROM dbo.ItemsPrices WHERE (PriceLVL_ID = 1) AND (Item_ID = dbo.Items.ID)), dbo.Items.StaticPrice) } END AS Price From dbo.MenuItems LEFT OUTER JOIN dbo.Items ON dbo.MenuItems.Item_ID = dbo.Items.ID Where (dbo.MenuItems.Preset_ID = " + MenuActivity.Prst_ID + ") AND (dbo.MenuItems.Rest_ID_Active = " + ConnectionClass.Rest_ID + ") AND (dbo.MenuItems.OutLet_ID_Active = " + ConnectionClass.OutletID + ") AND (dbo.Items.Active = 1) ORDER BY dbo.MenuItems.SortNumber";
ResultSet rs = ConnectionClass.Ret_RS(menuListSTR);
try {
while (rs.next()) {
SortedMap<String, String> sm = new TreeMap<String, String>();
sm.put("Item_ID", rs.getString("Item_ID"));
sm.put("Name", rs.getString("Name"));
sm.put("Price", rs.getString("Price"));
sm.put("PrintOnChick", rs.getString("PrintOnChick"));
sm.put("Taxable", rs.getString("Taxable"));
sm.put("NoServiceCharge", rs.getString("NoServiceCharge"));
sm.put("PrintOnReport", rs.getString("PrintOnReport"));
if (TablesFragment.Check_Items.containsKey(rs.getString("Item_ID"))) {
SortedMap<String, String> sm1 = TablesFragment.Check_Items.get(rs.getString("Item_ID"));
sm.put("Qty", sm1.get("Qty"));
} else
sm.put("Qty", "0");
alphabets.add(sm);
listMenuArray.add(rs.getString("Name"));
}
} catch (SQLException e) {
e.printStackTrace();
}
menuListView.setAdapter(new CustomMenuLVAdapter(this, listMenuArray, alphabets));
new MyAsyncTask().execute();
return rootView;
}
ProgressBar progressBar;
// The types specified here are the input data type, the progress type, and the result type
private class MyAsyncTask extends AsyncTask<String, Void, String> {
protected void onPreExecute() {
// Runs on the UI thread before doInBackground
// Good for toggling visibility of a progress indicator
progressBar.setVisibility(ProgressBar.VISIBLE);
}
protected String doInBackground(String... strings) {
String someBitmap ="";
String menuListSTR = "";
if (MenuActivity.Prst_ID.trim() == "-1")
menuListSTR = "Select ID,Code,Name,Name2 From Presets Where Active = 1 And Rest_ID_Active = 1 AND OutLet_ID_Active = 1 ORDER BY Code";
else
menuListSTR = "select dbo.MenuItems.Item_ID, dbo.Items.Code, dbo.Items.Name, dbo.Items.Name2, dbo.Items.PrintOnChick, dbo.Items.Taxable, dbo.Items.NoServiceCharge, dbo.Items.PrintOnReport,Case { fn IFNULL ((SELECT Price_Value FROM dbo.ItemsPrices WHERE (PriceLVL_ID = 1) AND (Item_ID = dbo.Items.ID)), 0) } when 0 then dbo.Items.StaticPrice Else { fn IFNULL ((SELECT Price_Value FROM dbo.ItemsPrices WHERE (PriceLVL_ID = 1) AND (Item_ID = dbo.Items.ID)), dbo.Items.StaticPrice) } END AS Price From dbo.MenuItems LEFT OUTER JOIN dbo.Items ON dbo.MenuItems.Item_ID = dbo.Items.ID Where (dbo.MenuItems.Preset_ID = " + MenuActivity.Prst_ID + ") AND (dbo.MenuItems.Rest_ID_Active = " + ConnectionClass.Rest_ID + ") AND (dbo.MenuItems.OutLet_ID_Active = " + ConnectionClass.OutletID + ") AND (dbo.Items.Active = 1) ORDER BY dbo.MenuItems.SortNumber";
ResultSet rs = ConnectionClass.Ret_RS(menuListSTR);
try {
while (rs.next()) {
SortedMap<String, String> sm = new TreeMap<String, String>();
sm.put("Item_ID", rs.getString("Item_ID"));
sm.put("Name", rs.getString("Name"));
sm.put("Price", rs.getString("Price"));
sm.put("PrintOnChick", rs.getString("PrintOnChick"));
sm.put("Taxable", rs.getString("Taxable"));
sm.put("NoServiceCharge", rs.getString("NoServiceCharge"));
sm.put("PrintOnReport", rs.getString("PrintOnReport"));
if (TablesFragment.Check_Items.containsKey(rs.getString("Item_ID"))) {
SortedMap<String, String> sm1 = TablesFragment.Check_Items.get(rs.getString("Item_ID"));
sm.put("Qty", sm1.get("Qty"));
} else
sm.put("Qty", "0");
alphabets.add(sm);
listMenuArray.add(rs.getString("Name"));
}
} catch (SQLException e) {
e.printStackTrace();
}
return someBitmap;
}
// protected void onProgressUpdate(Progress... values) {
// // Executes whenever publishProgress is called from doInBackground
// // Used to update the progress indicator
// progressBar.setProgress(values[0]);
// }
protected void onPostExecute(Bitmap result) {
// This method is executed in the UIThread
// with access to the result of the long running task
menuListView.setAdapter(new CustomMenuLVAdapter(this, listMenuArray, alphabets));
// Hide the progress bar
progressBar.setVisibility(ProgressBar.INVISIBLE);
}
}
}
这是我的适配器类
package abtech.waiteriano.com.waitrer.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.SortedMap;
import abtech.waiteriano.com.waitrer.R;
import abtech.waiteriano.com.waitrer.fragments.LVMenuFragment;
import abtech.waiteriano.com.waitrer.fragments.TablesFragment;
/**
* Created by dell on 3/7/2017.
*/
public class CustomMenuLVAdapter extends BaseAdapter {
ArrayList<String> resultMenuItems;
ArrayList<SortedMap> Items_Details;
LVItemHolder lvItemHolder;
Context context;
private static LayoutInflater inflater = null;
public CustomMenuLVAdapter(LVMenuFragment lvMenuFragment, ArrayList<String> listMenuArray, ArrayList<SortedMap> alphabets) {
resultMenuItems = listMenuArray;
Items_Details = alphabets;
context = lvMenuFragment.getActivity();
inflater = (LayoutInflater) context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return resultMenuItems.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public class LVItemHolder {
TextView listMenuTV, txtQTY;
RelativeLayout qtyView;
Button minusBtn;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final LVItemHolder lvItemHolder = new LVItemHolder();
View rowView;
rowView = inflater.inflate(R.layout.menu_list_item, null);
lvItemHolder.listMenuTV = (TextView) rowView.findViewById(R.id.menulistTV2);
lvItemHolder.txtQTY = (TextView) rowView.findViewById(R.id.txtQTY);
lvItemHolder.minusBtn = (Button) rowView.findViewById(R.id.minusBtn);
lvItemHolder.listMenuTV.setText(resultMenuItems.get(position));
SortedMap<String, String> sm = Items_Details.get(position);
lvItemHolder.txtQTY.setText(sm.get("Qty"));
rowView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int q = 0;
q = Integer.valueOf(lvItemHolder.txtQTY.getText().toString());
q++;
lvItemHolder.txtQTY.setText("" + q);
SortedMap<String, String> sm = Items_Details.get(position);
sm.put("Qty", "" + q);
TablesFragment.Check_Items.put(sm.get("Item_ID"), sm);
// Toast.makeText(context, "You Clicked "+resultMenuItems.get(position), Toast.LENGTH_LONG).show();
}
});
lvItemHolder.minusBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int q = 0;
q = Integer.valueOf(lvItemHolder.txtQTY.getText().toString());
if (q > 0)
q--;
lvItemHolder.txtQTY.setText("" + q);
SortedMap<String, String> sm = Items_Details.get(position);
sm.put("Qty", "" + q);
TablesFragment.Check_Items.put(sm.get("Item_ID"), sm);
}
});
return rowView;
}
}
android 监控错误
03-22 17:20:12.515 29962-30011/abtech.waiteriano.com.waitrer E/GED: Failed to get GED Log Buf, err(0)
03-22 17:20:12.531 29962-30011/abtech.waiteriano.com.waitrer E/[PropSet]: connect fail
03-22 17:20:12.531 29962-30011/abtech.waiteriano.com.waitrer E/libc: __system_property_set error : retry fail, errno 13(Permission denied)
03-22 17:20:12.531 29962-30011/abtech.waiteriano.com.waitrer E/[PropSet]: send_prop_msg return err -5
03-22 17:20:17.485 29962-29962/abtech.waiteriano.com.waitrer E/AndroidRuntime: FATAL EXCEPTION: main
Process: abtech.waiteriano.com.waitrer, PID: 29962
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference
at abtech.waiteriano.com.waitrer.fragments.LVMenuFragment$MyAsyncTask.onPreExecute(LVMenuFragment.java:85)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:591)
at android.os.AsyncTask.execute(AsyncTask.java:539)
at abtech.waiteriano.com.waitrer.fragments.LVMenuFragment.onCreateView(LVMenuFragment.java:76)
at android.app.Fragment.performCreateView(Fragment.java:2069)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:899)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1072)
at android.app.BackStackRecord.run(BackStackRecord.java:852)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6102)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
最佳答案
使用LVMenuFragment.this
,因为只有使用this
才会引用AsyncTask
类。您想要传递 LVMenuFragment
对象,而不是 AsyncTask
。
关于java - 创建异步任务时出现下划线错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42955751/
执行此查询 INSERT INTO classes( '_fkUserID', 'date', 'time' ) VALUES ( '1', '2017-07-04', '8:15' ) 给
不知道它是否重复(无法找到要搜索的词,例如 “允许使用 java 字符”)。我在测试面试中遇到了这个问题: 考虑以下类: class _ {_ f; _(){}_(_ f){_ t = f; f =
我需要验证用户的屏幕名称以确保它不能有 多个连字符或下划线 我不希望人们的网名全是标点符号。 这是我到目前为止的验证: public boolean validateScreenName(String
我正在尝试检查我收到的新数据是否针对我持有的对象,我想知道的是,我正在发送的对象的键是否与我当前拥有的对象中的任何键匹配。 所以我捕获了一个像 myObj = [{"one": 1}, {"two":
这是我第一次使用下划线...我有这个简单的 json... "categories" : [ { "tag" : "cat1", "active" : true
一个很简单的问题: 为什么在WPF内容中看不到_(下划线)? 例如内容 显示为"testt"(未显示下划线)。 最佳答案 标签支持助记符(即您可以使用ctrl +(key)赋予它们焦点)。您可以使用
下面是我正在处理的简化逻辑,我想在数组中查找具有匹配位置(文件夹)的文件。 我能够使用普通的 JS 循环来实现此功能,您能建议更好/更简单/类似下划线的方法来实现此类功能吗? // source va
我正在尝试在对象的函数中查找和替换值 我的对象看起来像这样: var testStates = [{ "module": "module1", "customUrl": [
尝试让 _.uniq() 在以下结构上工作: [ {'x' : 1, 'y': 2}, {'x' : 1, 'y': 2}, {'x' : 2, 'y': 3}, {'
明白了: [{ "title": "qq", "dateValuePair": { "date": "2016-04-29T22:00:00.000Z", "va
我不知道这是否可能,但我试图做的是“清理”一个对象。基本想法是我有一个对象的表格(以 Angular ),然后单击我想添加一个新行(控制对象中的一个新项目,但我希望它没有值。我有下划线尝试一下。一些考
所以我有一大堆对象需要将其变成一个小对象。 它有 50-60 个对象,我需要过滤到一个新的对象数组中,其中只有 3 个。 所以看起来像 myOb = {{"ob1": 1},{"ob2": 1},{"
我有一个像这样的对象 - {"house" : red, "car" : green, "apple" : blue}; 并且正在发送另一个带有单个键/值的对象,如下所示 {"apple" : gre
我有一个包含多个对象的数组,例如 var val = [ _id: ["5412fc1bd123cf7016674a92", "5412cf270e9ca9b517b43ca3"],
所以我有一个对象列表,例如 var options = [{"car" : "red"},{"house": "green"},{"dog":"bark"}] 我正在尝试将其转换为一个值数组,
我正在尝试将此数组转换为对象。使用下划线,我想转换这个数组: [ { "id": "parentA", "children": [ { "nam
我正在尝试使用这样的链检索嵌套项目值。我正在遍历的对象如下所示: var testStates = [{ "module": "module1", "customUrl
我有一些内容可编辑的段落,我希望能够在双击时使某些单词加粗下划线。当我双击一个单词时,它会被选中,并显示一个包含 3 个选项的工具提示。但是,单击工具提示选项后,选择就会消失,并且文本不会发生任何更改
要在 CSS 中给文本加下划线,我们可以这样做: h3 {text-decoration:underline;} 然而,这只会强调包含在 h3 标签中的文本。如果想让下划线穿过页面怎么办? 谢谢 最佳
我正在尝试解决我的最后一个问题,但我仍然不知道如何解决它。我的任务是编写一个对数字进行排序的程序,但是:我们的导师给了我们一些处理数字的程序的额外要点,例如:000054667(实际上是 54667)
我是一名优秀的程序员,十分优秀!