• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps SDK APK install issue

I am having some issues when trying to test my build in the SDK AVD emulator. Before the version 20 update of the eclipse plugin it was working but now it isn't Plus I am having a few issues with the device itself. I am just trying to make a simple application that displays the numbers you push, then clear out after you hit clear. In the old SDK it worked but on my TF101 the numbers wouldn't display. Any help would be appreciated.

Package Code:
Code:
package commbox.hptt;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import android.os.Bundle;

public class CommboxActivity extends Activity {
	private WebView mWebView;
	 private StringBuilder mMathString;
	 private ButtonClickListener mClickListener;
	 
	 /** Called when the activity is first created. */
	 @Override
	 public void onCreate(Bundle savedInstanceState) {
	  super.onCreate(savedInstanceState);
	  setContentView(R.layout.main);
	  
	  // Create the math string
	  mMathString = new StringBuilder();
	  
	  // Enable javascript for the view
	  mWebView = (WebView) findViewById(R.id.webview);
	  mWebView.getSettings().setJavaScriptEnabled(true);
	  mWebView.setBackgroundColor(Color.parseColor("#C0C0C0"));
	  mWebView.getSettings().setDefaultFontSize(500);
	  
	  // Set the listener for all the buttons
	  mClickListener = new ButtonClickListener();
	  int idList[] = { R.id.button0, R.id.button1, R.id.button2,
	    R.id.button3, R.id.button4, R.id.button5, R.id.button6,
	    R.id.button7, R.id.button8, R.id.button9,
	    R.id.buttonDecimal, R.id.buttonClear };

	  for(int id : idList) {
	   View v = findViewById(id);
	   v.setOnClickListener(mClickListener);
	  }

	 }
	 
	 private void updateWebView() {
	  
	  StringBuilder builder = new StringBuilder();
	  
	  builder.append("<html><body><center>");
	  builder.append("<script type=\"text/javascript\">document.write('");
	  builder.append(mMathString.toString());
	  builder.append("');");
	  builder.append("document.write( '' (\"");
	  builder.append(mMathString.toString());
	  builder.append("\"));</script>");
	  builder.append("</font></center></body></html>");

	  mWebView.loadData(builder.toString(), "application/xhtml", "UTF-8");
	 }

	 private class ButtonClickListener implements OnClickListener {

	  @Override
	  public void onClick(View v) {
	   switch (v.getId()) {
	   case R.id.buttonClear:
	    if(mMathString.length() > 0)
	     mMathString.delete(0, mMathString.length());
	    break;
	   default:
	    mMathString.append(((Button) v).getText());
	   }
	   
	   updateWebView();
	  }

	 }


}

XML Code:

Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/amdrpod"
    xmlns:android1="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android1:orientation="vertical" >
    
    <EditText android:id="@+id/txtFreq>"
    android:layout_height="wrap_content" android:textSize="56sp"
    android:typeface="monospace" android:textStyle="normal" android:text="0"
    android:gravity="bottom" android:layout_width="fill_parent" android:singleLine="true"/>
    
    <LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="horizontal"
    android:layout_weight="1">
    
    <Button android:id="@+id/btnOne" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    <Button android:id="@+id/btnTwo" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>

    <Button android:id="@+id/btnThree" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    </LinearLayout>
    
    <LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="horizontal"
    android:layout_weight="1">
    
    <Button android:id="@+id/btnFour" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    <Button android:id="@+id/btnFive" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>

    <Button android:id="@+id/btnSix" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    </LinearLayout>
    
    <LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="horizontal"
    android:layout_weight="1">
    
    <Button android:id="@+id/btnSeven" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    <Button android:id="@+id/btnEight" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>

    <Button android:id="@+id/btnNine" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    </LinearLayout>
    
    <LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="horizontal"
    android:layout_weight="1">
    
    <Button android:id="@+id/btnDecimal" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    <Button android:id="@+id/btnZero" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>

    <Button android:id="@+id/btnClear" android:padding="0px"
    android:text="9" android:gravity="center" android:typeface="monospace"
    android:textStyle="bold" android:textSize="24sp"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:layout_weight="1"/>
    
    </LinearLayout>    
</LinearLayout>
 
OK thanks. I am still having issues with this. I get the APK on the tablet, it loads, but the numbers don't appear on the webview.
 
Back
Top Bottom