我有一個litview在我的代碼和每個項目有一個edittext與一個按鈕,所以我想要做的是獲得edittext的值,當按下按鈕一個listview的項目。獲取一個列表視圖的EditText值,當它點擊它的項目
我試圖通過聲明它來獲取值,但它返回空值!
public View getView(int i, View view, ViewGroup viewGroup){
LayoutInflater linflater = getLayoutInflater();
View view1 = linflater.inflate(R.layout.row_view, null);
final EditText replyfld = (EditText) view1.findViewById(R.id.replyfld);
final Button sendreplybtn = (Button)view1.findViewById(R.id.sendreplybtn);
sendreplybtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String thereplyvalue = replyfld.getText().toString();
Toast.makeText(MessagesActivity.this, thereplyvalue, Toast.LENGTH_SHORT).show();
}
});
}
請問該做什麼?
什麼返回null?有什麼異常? –
感謝您的評論,它返回空值(意味着什麼都不返回)。 – Ghadeer
我的意思是代碼的哪一行。 –