Jump to content



Photo

android java help, please


  • Please log in to reply
3 replies to this topic

#1 Original Poster

Original Poster

    Systems Developer

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7/8, Kali, ubuntu, OSx 10.9
  • Phone: Android

Posted 23 February 2013 - 00:23

I have this bit of code and I am trying to get it working ... can you help me with the issues I have? which is to do with the R.layout... also point out any tips or hints on where to improve? I am just playing around at the moment getting used to it
package com.example.webu;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
public class MainActivity extends Activity {
SimpleAdapter adapter;
ArrayList<HashMap<String, String>> arraylist = new ArrayList<HashMap<String, String>>();
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
 
  ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
  NetworkInfo at = cm.getActiveNetworkInfo();
 
  final TextView tni = (TextView)findViewById(R.id.textView1);
  ListView lv = (ListView)findViewById(R.id.listView1);
 
 
  WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
  if(wifi.isWifiEnabled()) {
    List<ScanResult> scanResults = wifi.getScanResults();
    for(ScanResult scanRes : scanResults) {
		 this.adapter = new SimpleAdapter(MainActivity.this, arraylist, R.layout.rowLayout, new String[] { ITEM_KEY }, new int[] { R.id.list_value });
		  lv.setAdapter(this.adapter);
	 //tni.setText(scanRes.toString());
    }
  }
  //tni.setText(at.toString());
}
@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_main, menu);
  return true;
}
}



#2 Hardcore Til I Die

Hardcore Til I Die

    Neowinian Senior

  • Joined: 18-February 07
  • Location: England

Posted 06 March 2013 - 13:17

You want help with a problem, but you haven't said what the problem is.

I'm at a loss.... :(

#3 Detection

Detection

    Detecting stuff...

  • Joined: 30-October 10
  • Location: UK
  • OS: 7 SP1 x64

Posted 06 March 2013 - 13:23

Doesn't Eclipse highlight and hint on the problem ?

#4 OP Original Poster

Original Poster

    Systems Developer

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7/8, Kali, ubuntu, OSx 10.9
  • Phone: Android

Posted 28 March 2013 - 21:24

Doesn't Eclipse highlight and hint on the problem ?


nope lol I fixed this issue so long ago I have actually forgotten what the problem was :p