| | |
| Stránka: 1 z 1
| [ Príspevkov: 5 ] | |
Autor | Správa |
---|
Registrovaný: 11.02.09 Prihlásený: 28.03.23 Príspevky: 2208 Témy: 145 Bydlisko: Liptovský M... |
Vytvoril som si vlastny view definovany v triede DoubleNumberPicker.java kde sa snazim nacitat xml atributy do infoValue, maxValue a value: Kód: public class DoubleNumberPickerView extends LinearLayout {
public DoubleNumberPickerView(Context context, AttributeSet attrs) {
super(context, attrs); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.double_number_picker, this, true);
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DoubleNumberPickerView); infoValue = a.getString(R.styleable.DoubleNumberPickerView_info_text); maxValue = a.getInt(R.styleable.DoubleNumberPickerView_max_value, 99); value = a.getInt(R.styleable.DoubleNumberPickerView_value, 33); a.recycle();
setMaxValue(maxValue); setValue(value); setInfoValue(infoValue); update();
atributy tohto view objektu su jasne definovane v layoute s prefixom incredible: Kód: <LinearLayout xmlns:incredible="incredible.protest.stopwatchresultsaver.apk" android:layout_width="wrap_content" android:layout_height="wrap_content" >
<incredible.stopwatchresultssaver.stopwatchresultssaver.DoubleNumberPickerView android:id="@+id/hourpicker" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginRight="4dp" incredible:info_text="Hours" incredible:max_value="23" incredible:value="0" /> a tiez su povinne zapisane v subore attrs.xml presne podla tutorialov: Kód: <resources> <declare-styleable name="DoubleNumberPickerView"> <attr name="info_text" format="string" /> <attr name="max_value" format="integer" /> <attr name="value" format="integer" /> </declare-styleable> </resources> Tak preco mi nechce nacitavat tie atributy do premennych infoValue, maxValue, value a namiesto toho mi tam dava iba tie defaultne hodnoty 33, 99 ? Inak ten view vyzera takto:
_________________ "Only a warrior chooses pacifism, others are condemned to it." - unknown author |
|
Registrovaný: 05.04.11 Príspevky: 1693 Témy: 50 Bydlisko: Žilina, Pop... | Napísal XOLOO: 29.06.2014 8:26 | |
|
Pošli odkaz na ten návod. Edit: Kód: TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DoubleNumberPickerView); prečo voláš getContext() keď máš context ako parameter metódy ?
_________________ rMBP 13 2015 iPhone 7
|
|
Registrovaný: 11.02.09 Prihlásený: 28.03.23 Príspevky: 2208 Témy: 145 Bydlisko: Liptovský M... | |
Registrovaný: 05.04.11 Príspevky: 1693 Témy: 50 Bydlisko: Žilina, Pop... | Napísal XOLOO: 29.06.2014 12:27 | |
|
ten context nič nemení, ale bije to do oči ... tak isto ten tvoj namespace sa mi nepáči. Nezdá sa mi aby to tam tak fungoval. Prepíš to na niečo takéto : Kód: "http://schemas.android.com/apk/res/tvoj.package"
_________________ rMBP 13 2015 iPhone 7
|
|
Registrovaný: 11.02.09 Prihlásený: 28.03.23 Príspevky: 2208 Témy: 145 Bydlisko: Liptovský M... |
diky, uz to ide. aj ked tomu vobec nechapem, myslel som si ze tam moze byt hocico.
_________________ "Only a warrior chooses pacifism, others are condemned to it." - unknown author |
|
| Stránka: 1 z 1
| [ Príspevkov: 5 ] | |
Podobné témy | Témy | Odpovede | Zobrazenia | Posledný príspevok |
---|
| Generovanie XML:Chybná analýza XML: žiadny prvok sa nenašiel v HTML, XHTML, XML, CSS | 1 | 881 | 16.12.2011 16:49 Ďuri | | XML Schema => XML instance document v HTML, XHTML, XML, CSS | 0 | 733 | 02.11.2009 17:46 sINN3r | | atributy suborov v PHP, ASP | 10 | 891 | 13.07.2009 16:47 Snacker | | Atributy - Ubuntu v Operačné systémy Unix a Linux | 4 | 594 | 11.02.2009 18:27 Qpkqkma | | MSI FX 603 prečo áno, prečo nie? v Notebooky a netbooky | 5 | 1178 | 02.08.2011 22:15 KekkeiGenkai | | nefunkcna opera atributy ALT v Sieťové a internetové programy | 0 | 525 | 10.04.2009 15:11 ridick | | href ci ine atributy z iframe v JavaScript, VBScript, Ajax | 7 | 496 | 24.08.2017 21:29 neopagan | | TC: neviem zmenit atributy vzdialenych suborov v PHP, ASP | 2 | 725 | 29.05.2008 17:06 jaji | | hlaska - neregistrovana trieda v Antivíry a antispywary | 3 | 1283 | 08.04.2008 21:59 br4n0 | | Trieda v Jave v Assembler, C, C++, Pascal, Java | 3 | 390 | 07.02.2014 8:55 m@rtyn | | Nenacitava DVD9 v Optické zariadenia | 6 | 611 | 27.11.2010 19:01 mack0 | | Nenacitava stranky v Siete | 2 | 588 | 29.09.2016 17:18 LeaR | | Nenacitava klavesnicu v Externé zariadenia | 0 | 550 | 03.09.2009 15:56 jakub1114 | | python, trieda, mazanie suborov v Perl, Python, Ruby, CGI | 3 | 1273 | 28.05.2010 8:07 coldak | | Spolahlivy Phone/Stredna Trieda v Mobilné zariadenia | 6 | 689 | 27.11.2016 8:15 Smith Wesson | | CSS Vlastna trieda pre anchor v HTML, XHTML, XML, CSS | 2 | 365 | 08.03.2012 18:46 BlackB |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|