Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android TableLayout-应用程序已停止_Android - Fatal编程技术网

Android TableLayout-应用程序已停止

Android TableLayout-应用程序已停止,android,Android,运行应用程序时,我们收到一条错误消息“不幸的是,应用程序已停止”。调试时,我们收到一个错误,即找不到源 我们注意到添加tableLayout会导致以下问题: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pa

运行应用程序时,我们收到一条错误消息“不幸的是,应用程序已停止”。调试时,我们收到一个错误,即找不到源

我们注意到添加tableLayout会导致以下问题:

        <RelativeLayout 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:background="@drawable/background1"
    tools:context=".MainActivity" >

   <TableLayout
      android:id="@+id/tableLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true">

      <TableRow
          android:id="@+id/tableRow1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView

              android:id="@+id/textView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="0dp"
              android:layout_marginTop="24dp"
              android:text="Cell Id"
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle" />

      </TableRow>

      <TableRow
          android:id="@+id/tableRow2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Cell Location" 
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle"/>
      </TableRow>

      <TableRow
          android:id="@+id/tableRow3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="LAC" 
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle"/>
      </TableRow>

      <TableRow
          android:id="@+id/tableRow4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView4"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Signal Strength"
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle" />
      </TableRow>

      <TableRow
          android:id="@+id/tableRow5"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView5"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Rx Quality"
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle"/>
      </TableRow>

      <TableRow
          android:id="@+id/tableRow6"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView6"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="neighbor cells"
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle" />
      </TableRow>

      <TableRow
          android:id="@+id/tableRow7"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView7"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="send"
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle" />
      </TableRow>

      <TableRow
          android:id="@+id/tableRow8"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView8"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Scrambling code"
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle" />
      </TableRow>

      <TableRow
          android:id="@+id/tableRow9"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:padding="@string/padding" >

          <TextView
              android:id="@+id/textView9"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="N Cells" 
              android:textSize="@string/textsize"
              android:textStyle="@string/textstyle"/>
      </TableRow>

     <TableRow
          android:id="@+id/tableRow10"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" 
          android:paddingTop="30dp"
          android:paddingLeft="105dp"
           >
      <Button
          android:id="@+id/button1"

          android:onClick="press"

          android:text="PRESS" />
 </TableRow>
  </TableLayout>

</RelativeLayout>

Java代码:

package com.manish.tabdemo;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class HomeActivity extends Activity {
    TextView text,text2,text3,text4,text5,text6, text7, text8,text9;
    TelephonyManager Tel ;
    GsmCellLocation cellLocation; 
    SignalStrength signalStrength;
    MyPhoneStateListener    MyListener;
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        MyListener   = new MyPhoneStateListener();
        Tel       = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE);
        Tel.listen(MyListener ,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
        text = (TextView)findViewById(R.id.textView1);
        text2 = (TextView)findViewById(R.id.textView2);
        text3 = (TextView)findViewById(R.id.textView3);
        text4 = (TextView)findViewById(R.id.textView4);
        text5 = (TextView)findViewById(R.id.textView5);
        text6 = (TextView)findViewById(R.id.textView6);
        text7 = (TextView)findViewById(R.id.textView7);
        text8 = (TextView)findViewById(R.id.textView8);
        text9 = (TextView)findViewById(R.id.textView9);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_tab_host, menu);
        return true;
    }

    /* Get the Signal strength parameters */
    String RxLev, RxQual; 
    private class MyPhoneStateListener extends PhoneStateListener
    {
      @Override
      public void onSignalStrengthsChanged(SignalStrength signalStrength)
      {
        super.onSignalStrengthsChanged(signalStrength);
        RxLev = "RxLev = " + String.valueOf(signalStrength.getGsmSignalStrength()) + " dbM";
        RxQual = "RxQual = " +String.valueOf(signalStrength.getGsmBitErrorRate());
      }

    };


    //Reading longitude and latitude
    private static final String TAG = null; 
    String s;
    //String longitude;
    //String latitude;
    private class MyLocationListener implements LocationListener {

        @Override
        public void onLocationChanged(Location loc) {
            text6.setText("");
           // pb.setVisibility(View.INVISIBLE);
           Toast.makeText(
                 getBaseContext(),
                    "Location changed: Lat: " + loc.getLatitude() + " Lng: "
                        + loc.getLongitude(), Toast.LENGTH_SHORT).show();
           String longitude = "Longitude: " + loc.getLongitude();
            Log.v(TAG, longitude);
            String latitude = "Latitude: " + loc.getLatitude();
            Log.v(TAG, latitude);

            String s = longitude + "\n" + latitude ;
            text6.setText(s);

        }
        @Override
        public void onProviderDisabled(String provider) {}

        @Override
        public void onProviderEnabled(String provider) {}

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {}
    }


    int cid;
    int lac ;

    public void press(View v)
    {
        try
        {

        TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        GsmCellLocation cellLocation= (GsmCellLocation)telephonyManager.getCellLocation();
        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        LocationListener locationListener = new MyLocationListener();
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, locationListener);
        int psc = 0;//cellLocation.getPsc();
        Log.d(TAG, "PSC = " + psc);
        //Neighboring Cell  
        List<NeighboringCellInfo>  neighCell = null; 
        TelephonyManager telManager = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE); 
        neighCell = telManager.getNeighboringCellInfo();  
        String cells=""+neighCell.size();
        for (int i = 0; i < neighCell.size(); i++) 
        {  
            try {  
                  NeighboringCellInfo thisCell = neighCell.get(i);  
                  int thisNeighCID = thisCell.getCid();  
                  int thisNeighRSSI = thisCell.getRssi();  
                  cells = "1 "+thisNeighCID+" - "+thisNeighRSSI+"\n";  
                } 
            catch (NumberFormatException e) 
            {  
                  e.printStackTrace();
                  NeighboringCellInfo thisCell = neighCell.get(i);  
                  cells += neighCell.toString();  
            }  
       }  
         cid = cellLocation.getCid();
         text.setText("Cell id= " + String.valueOf(cid));
         text2.setText("Cell Location= "+cellLocation.toString());
         lac = cellLocation.getLac();
         text3.setText("Location Area Code= " + String.valueOf(lac));
         // view Rx Level
         text4.setText(RxLev);
         text5.setText(RxQual);
         // view longitude and latitude 
         //text5.setText(latitude);
        text7.setText("Scrambling code = " + psc);
        text8.setText("Neighboring Cells = " + cells);
         //text5.setText("Latitude= " + String.valueOf(lat));
        // text6.setText("Longitude= " + String.valueOf(lng));


        }

        catch(Exception e)
        {
            text5.setText(e.toString());

        }
    }


    HttpClient httpClient; 
    HttpPost httppost;
    ArrayList<NameValuePair> nameValuePairs; 
    HttpResponse response;
    HttpEntity entity;

    public void sendd(View v)
    {
        text4.setText("sendd");
          try 
          { 
             httpClient = new DefaultHttpClient();
             httppost = new HttpPost("http://10.0.2.2/syriatel/add.php");
             int uid = 0; 
             InputStream is = null;
             StringBuilder sb = null;
             String result; 
             nameValuePairs = new ArrayList<NameValuePair>();
             nameValuePairs.add(new BasicNameValuePair("id","3" ));
             nameValuePairs.add(new BasicNameValuePair("cell_name","ttty5y  "+cid));
             httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));


             response = httpClient.execute(httppost);
             HttpEntity entity = response.getEntity(); 
             is=entity.getContent();
             BufferedReader reader=new BufferedReader(new InputStreamReader(is, "iso-8859-1"),8);
             sb = new StringBuilder(); 
             sb.append(reader.readLine() + "\n");
             String line = "0"; 
             while ((line = reader.readLine()) != null)
             { 
                 sb.append(line + "\n");
             }
             is.close();
             result = sb.toString();
            text9.setText(result);

         }
         catch (Exception e) 
         {
             text5.setText( e.toString());
             Toast.makeText(getApplicationContext(), e.toString(), 1000);
             Log.e("errorin connection",e.toString()); 
             Toast.makeText(getApplicationContext(), e.toString(), 1000);} 

        }
}
package com.manish.tabdemo;
导入java.io.BufferedReader;
导入java.io.InputStream;
导入java.io.InputStreamReader;
导入java.util.ArrayList;
导入java.util.List;
导入org.apache.http.HttpEntity;
导入org.apache.http.HttpResponse;
导入org.apache.http.NameValuePair;
导入org.apache.http.client.HttpClient;
导入org.apache.http.client.entity.UrlEncodedFormEntity;
导入org.apache.http.client.methods.HttpPost;
导入org.apache.http.impl.client.DefaultHttpClient;
导入org.apache.http.message.BasicNameValuePair;
导入android.app.Activity;
导入android.content.Context;
导入android.location.location;
导入android.location.LocationListener;
导入android.location.LocationManager;
导入android.os.Bundle;
导入android.telephony.neightringcellinfo;
导入android.telephony.PhoneStateListener;
导入android.telephony.SignalStrength;
导入android.telephony.TelephonyManager;
导入android.telephony.gsm.GsmCellLocation;
导入android.util.Log;
导入android.view.Menu;
导入android.view.view;
导入android.widget.TextView;
导入android.widget.Toast;
公共类HomeActivity扩展了活动{
TextView文本、text2、text3、text4、text5、text6、text7、text8、text9;
电话经理电话;
GsmCellLocation细胞定位;
信号强度信号强度;
MyPhoneStateListener MyListener;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
MyListener=新的MyPhoneStateListener();
Tel=(TelephonyManager)getSystemService(Context.TELEPHONY_服务);
电话监听(MyListener、PhoneStateStener.listen\u信号强度);
text=(TextView)findViewById(R.id.textView1);
text2=(TextView)findViewById(R.id.textView2);
text3=(TextView)findViewById(R.id.textView3);
text4=(TextView)findViewById(R.id.textView4);
text5=(TextView)findViewById(R.id.textView5);
text6=(TextView)findViewById(R.id.textView6);
text7=(TextView)findViewById(R.id.textView7);
text8=(TextView)findViewById(R.id.textView8);
text9=(TextView)findViewById(R.id.textView9);
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.activity\u选项卡\u主机,菜单);
返回true;
}
/*获取信号强度参数*/
串RxLev,RxQual;
私有类MyPhoneStateListener扩展了PhoneStateListener
{
@凌驾
信号强度上的公共无效已更改(信号强度信号强度)
{
超级信号强度改变(信号强度);
RxLev=“RxLev=“+String.valueOf(signalStrength.getGsmSignalStrength())+“dbM”;
RxQual=“RxQual=“+String.valueOf(signalStrength.getgsmbiterrorate());
}
};
//经纬度读数
私有静态最终字符串标记=null;
字符串s;
//弦经度;
//弦纬度;
私有类MyLocationListener实现LocationListener{
@凌驾
位置更改后的公共无效(位置loc){
text6.setText(“”);
//pb.setVisibility(视图不可见);
Toast.makeText(
getBaseContext(),
位置已更改:纬度:“+loc.getLatitude()+”液化天然气:
+loc.getLongitude(),Toast.LENGTH_SHORT).show();
String longitude=“longitude:+loc.getLongitude();
Log.v(标签、经度);
String latitude=“latitude:+loc.getLatitude();
对数v(标签、纬度);
字符串s=经度+“\n”+纬度;
文本6.设置文本;
}
@凌驾
公共无效onProviderDisabled(字符串提供程序){}
@凌驾
公共无效onProviderEnabled(字符串提供程序){}
@凌驾
public void onStatusChanged(字符串提供程序、int状态、Bundle extra){}
}
int-cid;
int-lac;
公共媒体(视图五)
{
尝试
{
TelephonyManager TelephonyManager=(TelephonyManager)getSystemService(Context.TELEPHONY_服务);
GsmCellLocation cellLocation=(GsmCellLocation)telephonyManager.getCellLocation();
LocationManager LocationManager=(LocationManager)getSystemService(Context.LOCATION\u服务);
LocationListener LocationListener=新建MyLocationListener();
locationManager.RequestLocationUpdate(locationManager.GPS_提供程序,5000,10,locationListener);
int psc=0;//cellLocation.getPsc();
Log.d(标签“PSC=”+PSC);
//邻近细胞
List neighCell=null;
TelephonyManager=(TelephonyManager)getSystemService(Context.TELEPHONY_服务);
neighCell=telManager.getNeightringCellInfo();
字符串单元格=”“+neighCell.size();
对于(int i=0;i FATAL EXCEPTION: main
 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.manish.tabdemo/com.manish.tabdemo.TabHostActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.manish.tabdemo/com.manish.tabdemo.HomeActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.TableRow
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
    at android.app.ActivityThread.access$700(ActivityThread.java:159)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:5419)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.manish.tabdemo/com.manish.tabdemo.HomeActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.TableRow
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
    at android.app.ActivityThread.startActivityNow(ActivityThread.java:2135)
    at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
    at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
    at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:766)
    at android.widget.TabHost.setCurrentTab(TabHost.java:430)
    at android.widget.TabHost.addTab(TabHost.java:257)
    at com.manish.tabdemo.TabHostActivity.onCreate(TabHostActivity.java:26)
    at android.app.Activity.performCreate(Activity.java:5372)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
    ... 11 more
 Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.TableRow
    at android.view.LayoutInflater.createView(LayoutInflater.java:626)
    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
    at android.app.Activity.setContentView(Activity.java:1956)
    at com.manish.tabdemo.HomeActivity.onCreate(HomeActivity.java:47)
    at android.app.Activity.performCreate(Activity.java:5372)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
    ... 21 more
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
    at android.view.LayoutInflater.createView(LayoutInflater.java:600)
    ... 35 more
 Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3
    at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464)
    at android.view.View.<init>(View.java:3572)
    at android.view.ViewGroup.<init>(ViewGroup.java:475)
    at android.widget.LinearLayout.<init>(LinearLayout.java:176)
    at android.widget.LinearLayout.<init>(LinearLayout.java:172)
    at android.widget.T
    08-06 12:16:57.635: I/Process(29348): Sending signal. PID: 29348 SIG: 9
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.manish.tabdemo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.manish.tabdemo.TabHostActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.manish.tabdemo.HomeActivity"/>
             <activity android:name="com.manish.tabdemo.AboutActivity"/>
                  <activity android:name="com.manish.tabdemo.ContactActivity"/>
    </application>

</manifest>