Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android setText不在TextView上工作_Java_Android_Parse Platform - Fatal编程技术网

Java Android setText不在TextView上工作

Java Android setText不在TextView上工作,java,android,parse-platform,Java,Android,Parse Platform,我试图将Textview的值更改为我正在查询解析的某些信息,但由于某种原因,.setText没有生效 我尝试过谷歌搜索,但是.getString也不起作用。我对解析任何建议都很陌生 我的代码如下: import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View

我试图将Textview的值更改为我正在查询解析的某些信息,但由于某种原因,
.setText
没有生效

我尝试过谷歌搜索,但是
.getString
也不起作用。我对解析任何建议都很陌生

我的代码如下:

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;
}

}
导入android.os.Bundle;
导入android.support.v4.app.Fragment;
导入android.util.Log;
导入android.view.LayoutInflater;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.TextView;
导入com.parse.FindCallback;
导入com.parse.GetCallback;
导入com.parse.ParseException;
导入com.parse.ParseObject;
导入com.parse.ParseQuery;
导入org.w3c.dom.Text;
导入java.util.List;
/**
*一个简单的{@link Fragment}子类。
*/
公共类productDetail扩展了片段{
公共产品详情(){
//必需的空公共构造函数
}
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
最终视图视图=充气机。充气(R.layout.fragment\u product\u详图,容器,假);
final TextView productNameLabel=(TextView)theView.findViewById(R.id.productNameTextView);
最终文本视图productDetailsLabel=(文本视图)theView.findViewById(R.id.productDetails);
final TextView shippingFeeLabel=(TextView)theView.findViewById(R.id.shippingFee);
最终文本视图productPriceLabel=(文本视图)theView.findViewById(R.id.productPrice);
最终文本视图productNumberOfReviews标签=(文本视图)theView.findViewById(R.id.productNumberOfReviews);
最终字符串chosenProduct=getArguments().getString(“productName”);
Log.i(“AppInfo”,chosenProduct);
ParseQuery=新的ParseQuery(“库存”);
query.whereEqualTo(“产品名称”,chosenProduct);
getFirstInBackground(新的GetCallback(){
@凌驾
公共void完成(ParseObject ParseObject,parsee异常){
if(parseObject==null){
整数费=parseObject.getInt(“ShippingFee”);
Integer review=parseObject.getInt(“numberOfReviews”);
字符串信息=parseObject.get(“信息”).toString();
整数价格=parseObject.getInt(“价格”);
productNameLabel.setText(chosenProduct);
productDetailsLabel.setText(String.valueOf(information));
shippingfeelab.setText(String.valueOf(fee));
productPriceLabel.setText(String.valueOf(price));
ProductNumberOfReviewLabel.setText(String.valueOf(entries));
}
}
});
//为该碎片膨胀布局
返回视图;
}
}

如果输入,if语句中的所有内容都将抛出NullPointerException:)

将if语句更改为

if (parseObject != null)
或者你是这个意思

if (e == null) 

如果输入了NullPointerException,if语句中的所有内容都将抛出它:)

将if语句更改为

if (parseObject != null)
或者你是这个意思

if (e == null) 

parseObject
的值记录到控制台并检查其不规则性。将
parseObject
的值记录到控制台并检查其不规则性。谢谢,我刚刚在尝试记录错误时看到了这一点。我想你应该检查一下
e==null
,对吗?是的,我把它改成了e==null,不知道我是怎么把它混在一起的。我更新了答案。祝你的应用程序好运。谢谢。我刚在尝试记录errorWelcome时看到了这一点。我想你应该检查一下
e==null
,对吗?是的,我把它改成了e==null,不知道我是怎么把它混在一起的。我更新了答案。祝你的应用程序好运。