我尝试将Textview的值更改为我正在查询解析的某些信息,但出于某种原因,.setText
没有生效。
我尝试使用Google搜索,但.getString
也不起作用。我是Parse任何建议的新手?
我的代码如下:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.parse.FindCallback;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import org.w3c.dom.Text;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
*/
public class productDetail extends Fragment {
public productDetail() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View theView = inflater.inflate(R.layout.fragment_product_detail, container, false);
final TextView productNameLabel = (TextView) theView.findViewById(R.id.productNameTextView);
final TextView productDetailsLabel = (TextView) theView.findViewById(R.id.productDetails);
final TextView shippingFeeLabel = (TextView) theView.findViewById(R.id.shippingFee);
final TextView productPriceLabel = (TextView) theView.findViewById(R.id.productPrice);
final TextView productNumberOfReviewsLabel = (TextView) theView.findViewById(R.id.productNumberOfReviews);
final String chosenProduct = getArguments().getString("productName");
Log.i("AppInfo", chosenProduct);
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Inventory");
query.whereEqualTo("productName", chosenProduct);
query.getFirstInBackground(new GetCallback<ParseObject>() {
@Override
public void done(ParseObject parseObject, ParseException e) {
if (parseObject == null) {
Integer fee = parseObject.getInt("ShippingFee");
Integer review = parseObject.getInt("numberOfReviews");
String information = parseObject.get("information").toString();
Integer price = parseObject.getInt("price");
productNameLabel.setText(chosenProduct);
productDetailsLabel.setText(String.valueOf(information));
shippingFeeLabel.setText(String.valueOf(fee));
productPriceLabel.setText(String.valueOf(price));
productNumberOfReviewsLabel.setText(String.valueOf(entries));
}
}
});
// Inflate the layout for this fragment
return theView;
}
}
答案 0 :(得分:6)
if语句中的所有内容都会在输入时抛出NullPointerException :)
将if语句更改为此
padding-bottom:calc(33.3333333% - 1px);
或许你的意思是这个?
if (parseObject != null)