我是新手 自学的 :xutils框架:ViewUtils.inject ..."inject"是红色是什么问题 我是新手不懂。
我是参照http://m.blog.csdn.net/article/details?id=51422528 这里面设置的XUTILS 3.5.0版本
请大神们帮帮忙!
package fragment;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.ViewUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.luao2.jiemianzhuantiao.R;
import org.xutils.view.annotation.ViewInject;
/**
* Created by Administrator on 2017/4/4.
*/
public class FragmentHome extends Fragment{
@ViewInject(R.id.index_top_city)
private TextView index_top_city;
private String cityName;
private LocationManager locationManager;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.home_index, null);
ViewUtils.inject(this,view); //这里的inject是红色(没有inject方法)
return view;
}
}
你的ViewUtils导錯包了,导成import android.support.v7.widget.ViewUtils;这个了。换一下
studio 要同时加上
compile 'org.xutils:xutils:3.5.0'
compile 'com.jiechic.library:xUtils:2.6.14'
你可能是包导错了
我也遇到过这种问题
应该是import com.lidroid.xutils.ViewUtils;
而不是import android.support.v7.widget.ViewUtils;