Sign in to follow this  
Followers 0
Original Poster

android java help, please

4 posts in this topic

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;
}
}
[/CODE]

Share this post


Link to post
Share on other sites

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

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

Share this post


Link to post
Share on other sites

Doesn't Eclipse highlight and hint on the problem ?

Share this post


Link to post
Share on other sites

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

1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.