2012-05-10 50 views
0

我的计划是这样的添加一个TextView到的TableRow

`

public class InfoWifiActivity<Intent> extends Activity { 
    TableRow tr; 
    TextView temp; 

    public void onCreate(Bundle savedInstanceState) { 
     wifi.startScan(); 
     tr = new TableRow(this); 
     temp = new TextView(this); 

     IntentFilter i = new IntentFilter(); 
     i.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); 
     registerReceiver(new BroadcastReceiver(){ 

       @Override 
       public void onReceive(Context context, 
         android.content.Intent intent) { 
           temp.setText("SSID"); 
           temp.setPadding(0,0,3,0); 
           tr.addView(temp); 
} 
} 
}, i); 
} 
} 

`

但它一直FC当谈到tr.addView(临时);

任何人都可以帮助我吗?在此先感谢。

+0

logcat中的消息说什么时它强制关闭什么? – FoamyGuy

+0

它没有模拟器上的错误,因为它不具有wifi数据。只有在我的移动设备上,它保持fc –

+0

那么logcat输出在移动设备强制关闭时会显示什么? – FoamyGuy

回答

0

尝试设置TextView的高度和宽度,然后尝试。

tr.addView(temp,intWIDTH,intHEIGHT); 
+0

不幸的是,它不工作 tr.addView(temp,0,0); –

+0

你是否使用过任何布局?像线性还是相对? –

+0

我用相对和一个表和一个按钮。 如果我上传文件的某处,这会更容易,帮助我,不会吗? –