저는이 문제에 정말로 고심하고 있습니다. 수량을 증가시키고 수량을 기준으로 가격을 업데이트하는 간단한 텍스트 스위치를 사용하려고합니다. 바로 지금 내 XML에서 TextSwitcher 내에서 TextView와 같은 것을 사용하여 수량을 증가시킵니다. 나는 findViewById(R.id.quantity)
로 textview를 얻는다.TextSwitcher NullPointer 오류
은 그래서 이것은 내가 설정에 증가 수량 (내가하는 ViewFactory를 implemementing하고)
switcher = (TextSwitcher) findViewById(R.id.switcher);
switcher.setFactory(this);
quantity = (TextView) findViewById(R.id.quantity);
나는 또한 또한
@Override
public View makeView() {
return quantity;
}
증분 버튼 makeView()을 무시하고 찾을 수있다 것입니다 카운터가 증가하고 스위처의 텍스트를 현재 카운트로 설정합니다. 이와 같이 :
switcher.setText(String.valueOf(currentQuantity));
누군가 내가 내가 뭘 잘못하고 있는지 알려줄 수 있습니까 ?? 나는이 라인에서 내 nullpointer가 계속 : 여기
switcher.setFactory(this);
하면 XML 조각입니다 :
<TextSwitcher android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/switcher">
<TextView android:text="TextView" android:id="@+id/quantity" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</TextSwitcher>
당신이 게시 할 수 XML? – Torid
확실한 ive 업데이트 – HAxxor