android - error: Binary XML file line#3: You must supply a layout width attribute -
i'va read answers related these questions , i'm sure none solves problem, i'm getting crazy error, please appreciated
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="5dip" android:orientation="vertical" > <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/title_scaned_value"/> <textview android:id="@+id/scanedformat" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/title_scaned_value_empty"/> <textview android:id="@+id/scanedvalue" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/title_scaned_value_empty"/> <button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:text="@string/title_scan" android:onclick="commandscan"/> <button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:text="productes" android:onclick="productes"/>
my activity related layout works fine, when click button start activity error appears. i'm workin zxing library , here's captureactivity:
package org.example.sherlock_; import org.example.sherlock_.helpers.exceptionhelper; import android.content.intent; import android.graphics.bitmap; import com.google.zxing.result; import com.google.zxing.client.android.result.resulthandler; public class captureactivity extends com.google.zxing.client.android.captureactivity { @override public void handledecodeinternally(result rawresult, resulthandler resulthandler, bitmap barcode) { //super.handledecodeinternally(rawresult, resulthandler, barcode); try { intent resultintent = new intent(); resultintent.putextra(com.google.zxing.client.android.intents.scan.result_format, rawresult.getbarcodeformat().tostring()); resultintent.putextra(com.google.zxing.client.android.intents.scan.result, resulthandler.getdisplaycontents()); setresult(result_ok, resultintent); finish(); } catch (exception e) { exceptionhelper.manage(this, e); } }
}
i post mainactivity because i'm going mad :)
package org.example.sherlock_; import org.example.sherlock_.helpers.exceptionhelper; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.textview; import android.widget.toast; import com.actionbarsherlock.app.sherlockactivity; import com.actionbarsherlock.view.menu; import com.actionbarsherlock.view.menuinflater; import com.actionbarsherlock.view.menuitem; public class mainactivity extends sherlockactivity { private textview scanedvalue; private textview scanedformat; private final static int scan_code_request_code = 123456; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); scanedvalue = (textview)findviewbyid(r.id.scanedvalue); scanedformat = (textview)findviewbyid(r.id.scanedformat); } @override protected void onactivityresult(int prequestcode, int presultcode, intent pdata) { try { if (prequestcode == scan_code_request_code) { if (presultcode == result_ok) { string result = pdata.getstringextra (com.google.zxing.client.android.intents.scan.result); string format = pdata.getstringextra (com.google.zxing.client.android.intents.scan.result_format); if (scanedvalue != null) { if (result != null && !result.trim().equals("")) { scanedvalue.settext(result); //if(db != null){ //string valor= result ; //} } else { scanedvalue.settext(getstring(r.string.title_scaned_value_empty)); } } if (scanedformat != null) { if (format != null && !format.trim().equals("")) { scanedformat.settext(format); //if(db != null){ //string tipus = format; //} } else { scanedformat.settext(getstring(r.string.title_scaned_value_empty)); } } } else { if (scanedvalue != null) scanedvalue.settext(getstring(r.string.title_scaned_value_empty)); if (scanedformat != null) scanedformat.settext(getstring(r.string.title_scaned_value_empty)); } } //insertamos los datos en la tabla usuarios // db.execsql("insert productes (codi, tipus, valor) " + // "values (" + + ", '" + tipus +"', '"+ valor +"')"); // db.close(); //i+=i; } catch (exception e) { exceptionhelper.manage(this, e); } } public void commandscan(view pview) { try { intent captureintent = new intent(this, captureactivity.class); captureintent.putextra("scan_mode", "qr_code_mode"); startactivityforresult(captureintent, scan_code_request_code); } catch (exception e) { exceptionhelper.manage(this, e); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. menuinflater inflater = getsupportmenuinflater(); inflater.inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { if (item.getitemid() == r.id.action_settings) { toast.maketext(this, "configuraciĆ³n pulsado" , toast.length_short).show(); } return true; } }
Comments
Post a Comment