Czy ktoś wie, jak programowo ustawić tekst przycisku?Android Programowo ustawiający tekst przycisku
rzeczą nie wywołuję tego z głównego layoutu (setContentView) Wezwę to w widoku, który jest zawyżony po asynctask heres co próbowałem, ale daje to wyjątek wskaźnika pustego w drugiej linii
Button mButton=(Button)findViewById(R.id.contact);
mButton.setText("number");
herezje mój układ gdzie Wołam przycisk
<Button
android:id="@+id/contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/address"
android:layout_toLeftOf="@+id/badge"
android:background="@drawable/ic_btn_call"
android:textSize="10dp"
android:textStyle="bold"
android:textColor="@color/white"/>
tutaj moim zdaniem jestem pompowania
ClubInfo = LayoutInflater.from(getBaseContext()).inflate(R.layout.clubinfocell,
null);
TextView TeamNameText = (TextView) ClubInfo.findViewById(R.id.TeamName);
TeamNameText.setText(teamName);
TextView AddressText = (TextView) ClubInfo.findViewById(R.id.address);
AddressText.setText(address1);
Button mButton=(Button)ClubInfo.findViewById(R.id.contact);
mButton.setText(telephone);
można zamieścić swoje metody pełnej onCreate tutaj? – Cata
proszę podać pełny plik kodu Java. –
Daje NPE, ponieważ mButton ma wartość null w pierwszym wierszu. A to dlatego, że findViewById nie znalazł podanego przez Ciebie obiektu R.id.contact. –