Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot make a static reference to the non-static method findViewById(int) from the type Activity
    primarykey
    data
    text
    <p>I have the onclick in my (first)main activity. Where I call method pay() from another(second) activity class. I call the method here because the values i pass it in this class method.</p> <pre><code>tvdel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TableRow km= (TableRow)findViewById(tr.getId()); second.pay(dist1[km.getId()], pan1[km.getId()], taxno1[km.getId()],"N"); pay2(dist1[km.getId()], pan1[km.getId()], taxno1[km.getId()],"N"); } }); </code></pre> <p>Then if i settext to a text view i get this error.</p> <p>Error: Cannot make a static reference to the non-static method findViewById(int) from the type Activity</p> <pre><code>TextView test = (TextView)findViewById(R.id.otaxno); test.setText("try"); </code></pre> <p>I'm tried many solutions but nothing helped in my case. pls do help.</p> <p>My main activity class:</p> <pre><code>public String property(String taxtype, final String userid) { final String NAMESPACE = "http://tempuri.org/"; final String URL = "http://192.168.1.1/JavaService/Service.asmx"; final String SOAP_ACTION = "http://tempuri.org/GetTaxTypeDetails"; final String METHOD_NAME = "GetTaxTypeDetails"; Typeface tfavv = Typeface.createFromAsset(getAssets(),"fonts/Avvaiyar.ttf"); SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("sDistrict", dis); request.addProperty("sPanchayat", pan); request.addProperty("sTaxType", taxtype); request.addProperty("sTaxNo", taxno); request.addProperty("sTaxName", taxname); request.addProperty("sUserId", userid); DisAndPanDetails C = new DisAndPanDetails(); PropertyInfo pi = new PropertyInfo(); pi.setName("DisAndPanDetails"); pi.setValue(C); pi.setType(C.getClass()); request.addProperty(pi); SoapSerializationEnvelope envelope2 = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope2.dotNet = true; envelope2.setOutputSoapObject(request); envelope2.addMapping(NAMESPACE, "DisAndPanDetails", new DisAndPanDetails().getClass()); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.debug = true; try { androidHttpTransport.call(SOAP_ACTION, envelope2); SoapObject response2 = (SoapObject) envelope2.getResponse(); Log.i("myApp", response2.toString()); System.out.println("check dddddddddddddd" + response2); envelope2.addMapping(NAMESPACE, "Panchayat",new DisAndPanDetails().getClass()); androidHttpTransport.call(SOAP_ACTION, envelope2); final DisAndPanDetails[] personList2 = new DisAndPanDetails[response2.getPropertyCount()]; for (int j = 0; j &lt; personList2.length; j++) { SoapObject so = (SoapObject) response2.getProperty(j); DisAndPanDetails person2 = new DisAndPanDetails(); person2.TaxNo = so.getProperty(0).toString(); person2.TaxName= so.getPropertyAsString(1).toString(); person2.NoData=so.getPropertyAsString(6).toString(); person2.District=so.getPropertyAsString(7).toString(); person2.Panchayat=so.getPropertyAsString(8).toString(); person2.TaxType=so.getPropertyAsString(9).toString(); person2.TaxStatus=so.getPropertyAsString(10).toString(); personList2[j] = person2; } final String[] taxno1 = new String[personList2.length]; String[] taxname1 = new String[personList2.length]; dist1 = new String[personList2.length]; final String[] pan1 = new String[personList2.length]; final String[] taxtype1 = new String[personList2.length]; String[] status1 = new String[personList2.length]; System.out.println("stringarray: " + taxno1); String Nod = null; for (int i = 0; i &lt; personList2.length; i++) { taxno1[i] = Arrays.asList(personList2[i].TaxNo).toString().replace("[", "").replace("]", ""); taxname1[i] = Arrays.asList(personList2[i].TaxName).toString().replace("[", "").replace("]", ""); dist1[i] = Arrays.asList(personList2[i].District).toString().replace("[", "").replace("]", ""); pan1[i] = Arrays.asList(personList2[i].Panchayat).toString().replace("[", "").replace("]", ""); taxtype1[i] = Arrays.asList(personList2[i].TaxType).toString().replace("[", "").replace("]", ""); status1[i] = Arrays.asList(personList2[i].TaxStatus).toString().replace("[", "").replace("]", ""); Nod = personList2[i].NoData.toString(); System.out.println(taxno1[i]); System.out.println(taxname1[i]); System.out.println(dist1[i]); System.out.println(pan1[i]); System.out.println(taxtype1[i]); System.out.println(status1[i]); System.out.println("nod"+Nod); } TableLayout ll = (TableLayout) findViewById(R.id.tablelayout1); if ( Nod.equals("0")) {} else { for (i = 0; i &lt; personList2.length; i++) { final TableRow tr = new TableRow(this); // final TableRow tr = (TableRow)findViewById(R.id.tabrow2); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tr.setId(i); tr.setLayoutParams(lp); lp.setMargins(10, -10, 15, 5); final TextView tvLeft = new TextView(this); tvLeft.setLayoutParams(lp); tvLeft.setGravity(Gravity.CENTER); tvLeft.setText(taxno1[i]); final TextView tvCenter = new TextView(this); tvCenter.setLayoutParams(lp); tvCenter.setTypeface(tfavv); tvCenter.setText(taxname1[i]); final TextView tvRight = new TextView(this); tvRight.setLayoutParams(lp); tvRight.setText(pan1[i]); final TextView tvend = new TextView(this); tvend.setLayoutParams(lp); tvend.setText(dist1[i]); final TextView tvdel = new TextView(this); tvdel.setLayoutParams(lp); tvdel.setTextSize(20); tvdel.setGravity(Gravity.CENTER); tvdel.setTextColor(Color.GREEN); tvdel.setText("Pay"); tvdel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent login = new Intent(getApplicationContext(), PropertyTaxpay.class); login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); login.putExtra("no",taxno1); startActivity(login); TableRow km= (TableRow)findViewById(tr.getId()); System.out.println(km); System.out.println("clickeddddddddddd tr"+tr.getId()); System.out.println("clickeddddddddddd km "+km.getId()); System.out.println("clickeddddddddddd i"+i); PropertyTaxpay.pay(dist1[km.getId()], pan1[km.getId()], taxno1[km.getId()],"P"); // pay2(dist1[km.getId()], pan1[km.getId()], taxno1[km.getId()],"P"); } } ); tr.addView(tvLeft); tr.addView(tvCenter); tr.addView(tvRight); tr.addView(tvend); tr.addView(tvdel); ll.addView(tr, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); } for (int i = 0; i &lt; personList2.length; i++) { System.out.println("last TaxNo: " + personList2[i].TaxNo); System.out.println("last TaxName: " + personList2[i].TaxName); System.out.println("last District: "+ personList2[i].District); System.out.println("last Panchayat: " + personList2[i].Panchayat); System.out.println("last TaxType: " + personList2[i].TaxType); System.out.println("last TaxStatus: " + personList2[i].TaxStatus); System.out.println(" "); System.out.println(" "); System.out.println(" "); System.out.println(" "); System.out.println(" "); } } } catch (SocketException ex) { Log.e("Error : ", "Error on soapPrimitiveData() " + ex.getMessage()); ex.printStackTrace(); } catch (Exception e) { Log.e("Error : ", "Error soapPrimitiveData() " + e.getMessage()); e.printStackTrace(); } return null; } </code></pre> <p>In second activity class:</p> <pre><code>protected static String pay(String dist, String pan,String taxno, String taxtype ) { final String NAMESPACE = "http://tempuri.org/"; final String URL = "http://192.168.1.1/JavaService/Service.asmx"; final String SOAP_ACTION = "http://tempuri.org/GetTaxDetails"; final String METHOD_NAME = "GetTaxDetails"; SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("sDistrict", dist); request.addProperty("sPanchayat", pan); request.addProperty("sTaxType", taxtype); request.addProperty("sTaxNo", taxno); DisAndPanDetails D = new DisAndPanDetails(); PropertyInfo pi = new PropertyInfo(); pi.setName("DisAndPanDetails"); pi.setValue(D); pi.setType(D.getClass()); request.addProperty(pi); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); System.out.println(request); envelope.addMapping(NAMESPACE, "DisAndPanDetails", new DisAndPanDetails().getClass()); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.debug = true; try { androidHttpTransport.call(SOAP_ACTION, envelope); SoapObject response2 = (SoapObject) envelope.getResponse(); Log.i("myApp", response2.toString()); System.out.println("clicvvvvvvvv dddddddddddddd" + response2); String resultData = response2.getProperty(0).toString(); System.out.println("clicvvvvvvvv resultData" + resultData); DisAndPanDetails[] personList2 = new DisAndPanDetails[response2.getPropertyCount()]; for (int j = 0; j &lt; personList2.length; j++) { DisAndPanDetails person2 = new DisAndPanDetails(); person2.TaxName= response2.getProperty(0).toString(); person2.TaxDoorNo=response2.getProperty(1).toString(); person2.TaxStreetName=response2.getPropertyAsString(2).toString(); person2.TaxWardNo=response2.getPropertyAsString(3).toString(); person2.Error=response2.getPropertyAsString(4).toString(); person2.MobileNo=response2.getPropertyAsString(5).toString(); person2.NoData=response2.getPropertyAsString(6).toString(); person2.NonTaxRights=response2.getPropertyAsString(7).toString(); personList2[j] = person2; } String TaxName1 ; String TaxDoorNo1 ; String TaxStreetName1 ; String TaxWardNo1 ; String NonTaxRights1 ; String NoData1; String Error1; String MobileNo1; int i=0; TaxName1 = personList2[i].TaxName.toString(); TaxDoorNo1 = personList2[i].TaxDoorNo.toString(); TaxStreetName1 = personList2[i].TaxStreetName.toString(); TaxWardNo1 = personList2[i].TaxWardNo.toString(); NonTaxRights1 = personList2[i].NonTaxRights.toString(); NoData1 = personList2[i].NoData.toString(); Error1 = personList2[i].Error.toString(); MobileNo1 = personList2[i].MobileNo.toString(); System.out.println("TaxName1"+TaxName1); System.out.println("TaxDoorNo1"+TaxDoorNo1); System.out.println("TaxStreetName1"+TaxStreetName1); System.out.println("TaxWardNo1"+TaxWardNo1); System.out.println("NonTaxRights1"+NonTaxRights1); System.out.println("NoData1"+NoData1); System.out.println("Error1"+Error1); System.out.println("MobileNo1"+MobileNo1); /* LayoutInflater inflater =(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.payment, null); TextView test = (TextView)v.findViewById(R.id.otaxno); test.setText("try"); */ TextView test = (TextView)getActivity().findViewById(R.id.otaxno); test.setText("try"); } catch (SocketException ex) { Log.e("Error : ", "Error on soapPrimitiveData() " + ex.getMessage()); ex.printStackTrace(); } catch (Exception e) { Log.e("Error : ", "Error soapPrimitiveData() " + e.getMessage()); e.printStackTrace(); } return null; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload