Java 如何在其他活动中输入URL数据
如何在WV活动中输入URL数据 我希望我能告诉你。提前谢谢你的帮助 这是我的意图按钮Java 如何在其他活动中输入URL数据,java,android,android-intent,Java,Android,Android Intent,如何在WV活动中输入URL数据 我希望我能告诉你。提前谢谢你的帮助 这是我的意图按钮 button = (Button) findViewById(R.id.haftalikizle); button.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { Intent i =
button = (Button) findViewById(R.id.haftalikizle);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), VW.class);
i.putExtra("link",(KEY_URL).toString());
startActivity(i);
}});
这是我的完整代码,但不起作用。想法,想法,或者你可以编辑你的
public class haftalik extends ListActivity {
static final String URL = "https://dl.dropboxusercontent.com/s/qd33n0zxcmrnsf2/haftalik.xml";
static final String KEY_ITEM = "item";
static final String KEY_ID = "id";
static final String KEY_BILGI = "bilgi";
static final String KEY_URL = "url";
static final String KEY_THUMB_URL = "thumb_url";
public WebView tarayici;
private ProgressDialog pDialog;
ConnectivityManager connectivity = null;
ListView lv;
haftalik2 adapter;
ArrayList<HashMap<String, String>> catalogList;
Button button;
//@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.haftalik_main);
if(isConn())
{
catalogList= new ArrayList<HashMap<String, String>>();
new LoadCatalog().execute();
}
else
{
Intent i = new Intent(getApplicationContext(), dene.class);
startActivity(i);
this.finish();
}
}
class LoadCatalog extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(haftalik.this);
// pDialog.setMessage("");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
protected String doInBackground(String... args) {
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL); // getting XML from URL
Document doc = parser.getDomElement(xml); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_ITEM);
// looping through all song nodes <song>
for (int i = 0; i < nl.getLength(); i++) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map.put(KEY_ID, parser.getValue(e, KEY_ID));
map.put(KEY_BILGI, parser.getValue(e, KEY_BILGI));
map.put(KEY_URL, parser.getValue(e, KEY_URL));
map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL));
// adding HashList to ArrayList
catalogList.add(map);
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
lv=getListView();
adapter=new haftalik2(haftalik.this, catalogList);
lv.setAdapter(adapter);
pDialog.dismiss();
}
});
button = (Button) findViewById(R.id.haftalikizle);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i = new Intent(getApplicationContext(), VW.class);
i.putExtra("link",(KEY_URL).toString());
startActivity(i);
}});
}
}
public boolean isConn(){
connectivity = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if(connectivity.getActiveNetworkInfo()!=null){
if(connectivity.getActiveNetworkInfo().isConnected())
return true;
}
return false;
}
}
公共类haftalik扩展了ListActivity{
静态最终字符串URL=”https://dl.dropboxusercontent.com/s/qd33n0zxcmrnsf2/haftalik.xml";
静态最终字符串键\u ITEM=“ITEM”;
静态最终字符串键\u ID=“ID”;
静态最终字符串键\u BILGI=“BILGI”;
静态最终字符串键\u URL=“URL”;
静态最终字符串键\u THUMB\u URL=“THUMB\u URL”;
公共网络视图tarayici;
私人对话;
ConnectionManager连接性=空;
ListView lv;
haftalik2适配器;
ArrayList目录列表;
按钮;
//@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(haftalik_main右侧布局);
if(isConn())
{
catalogList=新的ArrayList();
新建LoadCatalog().execute();
}
其他的
{
Intent i=新Intent(getApplicationContext(),dene.class);
星触觉(i);
这个;
}
}
类LoadCatalog扩展了异步任务{
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
pDialog=newprogressdialog(haftalik.this);
//pDialog.setMessage(“”);
pDialog.setUndeterminate(假);
pDialog.setCancelable(假);
pDialog.show();
}
受保护的字符串doInBackground(字符串…args){
XMLParser=新的XMLParser();
字符串xml=parser.getXmlFromUrl(URL);//从URL获取xml
Document doc=parser.getDomeElement(xml);//获取DOM元素
NodeList nl=doc.getElementsByTagName(键项);
//通过所有歌曲节点循环播放歌曲
对于(int i=0;i
还有我的适配器类
public class haftalik2 extends BaseAdapter {
String url=null;
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public haftalik2(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.haftalik, null);
TextView bilgi = (TextView)vi.findViewById(R.id.bilgi);
//TextView url = (TextView)vi.findViewById(R.id.url);
ImageView thumb_image=(ImageView)vi.findViewById(R.id.poster);
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(position);
bilgi.setText(song.get(haftalik.KEY_BILGI));
//url.setText(song.get(haftalik.KEY_URL));
imageLoader.DisplayImage(song.get(haftalik.KEY_THUMB_URL), thumb_image);
return vi;
}
}
公共类haftalik2扩展BaseAdapter{
字符串url=null;
私人活动;
私有数组列表数据;
专用静态充气机=空;
公共图像加载器;
公共haftalik2(活动a,阵列列表d){
活动=a;
数据=d;
充气器=(LayoutInflater)activity.getSystemService(Context.LAYOUT\u充气器\u SERVICE);
imageLoader=新的imageLoader(activity.getApplicationContext());
}
public int getCount(){
返回data.size();
}
公共对象getItem(int位置){
返回位置;
}
公共长getItemId(int位置){
返回位置;
}
公共视图getView(int位置、视图转换视图、视图组父视图){
视图vi=转换视图;
if(convertView==null)
vi=充气机充气(R.layout.haftalik,空);
TextView-bilgi=(TextView)vi.findViewById(R.id.bilgi);
//TextView url=(TextView)vi.findViewById(R.id.url);
ImageView拇指图像=(ImageView)vi.findViewById(R.id.poster);
HashMap宋=新HashMap();
宋=数据。获取(位置);
bilgi.setText(song.get(haftalik.KEY_bilgi));
//setText(song.get(haftalik.KEY_url));
imageLoader.DisplayImage(song.get(haftalik.KEY\u THUMB\u URL)、THUMB\u image);
返回vi;
}
}
您在传递额外意向时遇到问题?请您再解释一下好吗?