7 个按钮、3 个异步任务、1 个活动和一场噩梦

发布于 2024-12-07 10:09:14 字数 15542 浏览 1 评论 0原文

正当我以为我已经解决了这个问题时,我意识到我只能按照 Activity.java 中编写的顺序使用活动中的按钮(例如:无法执行按钮 5 按下,直到 1,2,3, 4个都被按下了!) 我该如何解决这个问题?

Activity.Java:

public class TwoActivity extends Activity {

ProgressBar progressBar;
TextView textView41;
TextView textView42;
TextView textView43;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.two);

    progressBar = (ProgressBar)findViewById(R.id.progressbar_Horizontal);
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.blue_progress));
    textView41 = (TextView)findViewById(R.id.dl41text);
    textView42 = (TextView)findViewById(R.id.dl42text);
    textView43 = (TextView)findViewById(R.id.dl43text);


    Button button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startDownload();

        }
    });
}
private void startDownload() {
    String url = "http://dl.dropbox.com/u/43058382/steelers1.jpg";
    new DownloadFileAsync().execute(url);
}

class DownloadFileAsync extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
    progressBar.setProgress(0);
    progressBar.setVisibility(View.VISIBLE);
    textView41.setVisibility(View.VISIBLE);
    super.onPreExecute();
}

@Override
protected String doInBackground(String... aurl) {
    int count;

try {

URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();

int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/steelers1.jpg");

byte data[] = new byte[1024];

long total = 0;

    while ((count = input.read(data)) != -1) {
        total += count;
        publishProgress(""+(int)((total*100)/lenghtOfFile));
        output.write(data, 0, count);
    }

    output.flush();
    output.close();
    input.close();
} catch (Exception e) {}
return null;

}
protected void onProgressUpdate(String... progress) {
    progressBar.setProgress(Integer.parseInt(progress[0]));
}

@Override
protected void onPostExecute(String unused) {
    progressBar.setVisibility(View.INVISIBLE);
    textView41.setVisibility(View.INVISIBLE);


    Button button2 = (Button) findViewById(R.id.button2);
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View w) {
            startDownload();

        }
    });
}
private void startDownload() {
    String url = "http://dl.dropbox.com/u/43058382/steelers2.jpg";
    new DownloadFileAsync2().execute(url);
}

class DownloadFileAsync2 extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
    progressBar.setProgress(0);
    progressBar.setVisibility(View.VISIBLE);
    textView42.setVisibility(View.VISIBLE);
    super.onPreExecute();
}

@Override
protected String doInBackground(String... aurl) {
    int count;

try {

URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();

int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/steelers2.jpg");

byte data[] = new byte[1024];

long total = 0;

    while ((count = input.read(data)) != -1) {
        total += count;
        publishProgress(""+(int)((total*100)/lenghtOfFile));
        output.write(data, 0, count);
    }

    output.flush();
    output.close();
    input.close();
} catch (Exception e) {}
return null;

}
protected void onProgressUpdate(String... progress) {
    progressBar.setProgress(Integer.parseInt(progress[0]));
}

@Override
protected void onPostExecute(String unused) {
    progressBar.setVisibility(View.INVISIBLE);
    textView42.setVisibility(View.INVISIBLE);

    Button button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View w) {
            startDownload();

        }
    });
}
private void startDownload() {
    String url = "http://dl.dropbox.com/u/43058382/steelers3.jpg";
    new DownloadFileAsync3().execute(url);
}

class DownloadFileAsync3 extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
    progressBar.setProgress(0);
    progressBar.setVisibility(View.VISIBLE);
    textView43.setVisibility(View.VISIBLE);
    super.onPreExecute();
}

@Override
protected String doInBackground(String... aurl) {
    int count;

try {

URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();

int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/steelers3.jpg");

byte data[] = new byte[1024];

long total = 0;

    while ((count = input.read(data)) != -1) {
        total += count;
        publishProgress(""+(int)((total*100)/lenghtOfFile));
        output.write(data, 0, count);
    }

    output.flush();
    output.close();
    input.close();
} catch (Exception e) {}
return null;

}
protected void onProgressUpdate(String... progress) {
    progressBar.setProgress(Integer.parseInt(progress[0]));
}

@Override
protected void onPostExecute(String unused) {
    progressBar.setVisibility(View.INVISIBLE);
    textView43.setVisibility(View.INVISIBLE);

    Button button16 = (Button) findViewById(R.id.button16);
    button16.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Intent myIntent = new
                    Intent(TwoActivity.this, ModdifyMyWiiActivity.class);
            TwoActivity.this.startActivity(myIntent);
        }
    });

    Button button18 = (Button) findViewById(R.id.button18);
    button18.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Intent myIntent = new
                    Intent(TwoActivity.this, ThreeActivity.class);
            TwoActivity.this.startActivity(myIntent);
        }
    });

    Button button19 = (Button) findViewById(R.id.button19);
    button19.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Intent myIntent = new
                    Intent(TwoActivity.this, FourActivity.class);
            TwoActivity.this.startActivity(myIntent);
        }
    });
}


    public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.menu, menu);
            return true;

    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.menuexit:
            final Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_HOME);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            break;
        case R.id.menucontact:
            final Intent intent1 = new Intent(android.content.Intent.ACTION_SEND);
            intent1.setType("text/plain");
            intent1.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
            intent1.putExtra(android.content.Intent.EXTRA_SUBJECT, "Transform Mii Help");
            final PackageManager pm = getPackageManager();
            final List<ResolveInfo> matches = pm.queryIntentActivities(intent1, 0);
            ResolveInfo best = null;
            for (final ResolveInfo info : matches)
              if (info.activityInfo.packageName.endsWith(".gm") ||
                  info.activityInfo.name.toLowerCase().contains("gmail")) best = info;
            if (best != null)
              intent1.setClassName(best.activityInfo.packageName, best.activityInfo.name);
            startActivity(intent1);

            break;
        }
        return true;

    }
}
}
}
}

而她的是layout.xml:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/main_bg_hdpi" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:weightSum="1">
    <ScrollView android:id="@+id/scrollView1" android:layout_centerHorizontal="true" android:layout_alignParentTop="true" android:layout_width="match_parent" android:layout_height="390dp">
        <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:orientation="vertical" android:weightSum="1" android:layout_height="wrap_content">
            <Button android:src="@drawable/fourone_files" android:background="@drawable/modfiles41" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:src="@drawable/fourtwo_files" android:background="@drawable/modfiles42" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2" android:layout_alignTop="@+id/button1" android:layout_centerHorizontal="true"></Button>
            <Button android:src="@drawable/fourthree_files" android:background="@drawable/modfiles43" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3" android:layout_alignTop="@+id/button2" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button4" android:layout_below="@+id/button3" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button5" android:layout_alignBottom="@+id/button4" android:layout_centerHorizontal="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button6" android:layout_alignBottom="@+id/button5" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button7" android:layout_below="@+id/button4" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button8" android:layout_alignBottom="@+id/button7" android:layout_alignLeft="@+id/button5"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button9" android:layout_alignBottom="@+id/button8" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button10" android:layout_below="@+id/button7" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button11" android:layout_alignBottom="@+id/button10" android:layout_alignLeft="@+id/button8"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button12" android:layout_alignTop="@+id/button11" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button13" android:layout_below="@+id/button10" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button14" android:layout_alignBottom="@+id/button13" android:layout_alignLeft="@+id/button2"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button15" android:layout_alignBottom="@+id/button14" android:layout_alignParentRight="true"></Button>
            <TextView android:text="** Get your System Menu Version by accessing the Wii Options Menu " android:id="@+id/CustomFontText" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:paddingLeft="5dip" android:paddingRight="5dip" android:focusable="true" android:focusableInTouchMode="true" android:freezesText="true" android:textColor="@color/wiiblue" android:textStyle="bold" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>
            <ProgressBar android:layout_width="fill_parent" android:layout_height="35dp" style="?android:attr/progressBarStyleHorizontal" android:id="@+id/progressbar_Horizontal" android:max="100" android:layout_below="@+id/button15" android:layout_marginTop="15dp" android:visibility="invisible" ></ProgressBar>
            <TextView android:id="@+id/dl41text" android:text="Downloading 4.1 Mod Pack..." android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/white" android:textStyle="bold" android:gravity="center" android:visibility="invisible" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>
            <TextView android:id="@+id/dl42text" android:text="Downloading 4.2 Mod Pack..." android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/white" android:textStyle="bold" android:gravity="center" android:visibility="invisible" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>
            <TextView android:id="@+id/dl43text" android:text="Downloading 4.3 Mod Pack..." android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/white" android:textStyle="bold" android:gravity="center" android:visibility="invisible" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>

        </RelativeLayout>

    </ScrollView>

>>

菜单也不显示!感谢所有帮助!

Just when I thought I had this one cinched, I realized that I can only use the buttons in the activity in the same sequence they are written in the Activity.java (Ex: Cannot execute button 5 press, until 1,2,3,and 4 have all been pressed!)
How do I fix this?

Activity.Java:

public class TwoActivity extends Activity {

ProgressBar progressBar;
TextView textView41;
TextView textView42;
TextView textView43;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.two);

    progressBar = (ProgressBar)findViewById(R.id.progressbar_Horizontal);
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.blue_progress));
    textView41 = (TextView)findViewById(R.id.dl41text);
    textView42 = (TextView)findViewById(R.id.dl42text);
    textView43 = (TextView)findViewById(R.id.dl43text);


    Button button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startDownload();

        }
    });
}
private void startDownload() {
    String url = "http://dl.dropbox.com/u/43058382/steelers1.jpg";
    new DownloadFileAsync().execute(url);
}

class DownloadFileAsync extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
    progressBar.setProgress(0);
    progressBar.setVisibility(View.VISIBLE);
    textView41.setVisibility(View.VISIBLE);
    super.onPreExecute();
}

@Override
protected String doInBackground(String... aurl) {
    int count;

try {

URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();

int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/steelers1.jpg");

byte data[] = new byte[1024];

long total = 0;

    while ((count = input.read(data)) != -1) {
        total += count;
        publishProgress(""+(int)((total*100)/lenghtOfFile));
        output.write(data, 0, count);
    }

    output.flush();
    output.close();
    input.close();
} catch (Exception e) {}
return null;

}
protected void onProgressUpdate(String... progress) {
    progressBar.setProgress(Integer.parseInt(progress[0]));
}

@Override
protected void onPostExecute(String unused) {
    progressBar.setVisibility(View.INVISIBLE);
    textView41.setVisibility(View.INVISIBLE);


    Button button2 = (Button) findViewById(R.id.button2);
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View w) {
            startDownload();

        }
    });
}
private void startDownload() {
    String url = "http://dl.dropbox.com/u/43058382/steelers2.jpg";
    new DownloadFileAsync2().execute(url);
}

class DownloadFileAsync2 extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
    progressBar.setProgress(0);
    progressBar.setVisibility(View.VISIBLE);
    textView42.setVisibility(View.VISIBLE);
    super.onPreExecute();
}

@Override
protected String doInBackground(String... aurl) {
    int count;

try {

URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();

int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/steelers2.jpg");

byte data[] = new byte[1024];

long total = 0;

    while ((count = input.read(data)) != -1) {
        total += count;
        publishProgress(""+(int)((total*100)/lenghtOfFile));
        output.write(data, 0, count);
    }

    output.flush();
    output.close();
    input.close();
} catch (Exception e) {}
return null;

}
protected void onProgressUpdate(String... progress) {
    progressBar.setProgress(Integer.parseInt(progress[0]));
}

@Override
protected void onPostExecute(String unused) {
    progressBar.setVisibility(View.INVISIBLE);
    textView42.setVisibility(View.INVISIBLE);

    Button button3 = (Button) findViewById(R.id.button3);
    button3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View w) {
            startDownload();

        }
    });
}
private void startDownload() {
    String url = "http://dl.dropbox.com/u/43058382/steelers3.jpg";
    new DownloadFileAsync3().execute(url);
}

class DownloadFileAsync3 extends AsyncTask<String, String, String> {

@Override
protected void onPreExecute() {
    progressBar.setProgress(0);
    progressBar.setVisibility(View.VISIBLE);
    textView43.setVisibility(View.VISIBLE);
    super.onPreExecute();
}

@Override
protected String doInBackground(String... aurl) {
    int count;

try {

URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();

int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);

InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/steelers3.jpg");

byte data[] = new byte[1024];

long total = 0;

    while ((count = input.read(data)) != -1) {
        total += count;
        publishProgress(""+(int)((total*100)/lenghtOfFile));
        output.write(data, 0, count);
    }

    output.flush();
    output.close();
    input.close();
} catch (Exception e) {}
return null;

}
protected void onProgressUpdate(String... progress) {
    progressBar.setProgress(Integer.parseInt(progress[0]));
}

@Override
protected void onPostExecute(String unused) {
    progressBar.setVisibility(View.INVISIBLE);
    textView43.setVisibility(View.INVISIBLE);

    Button button16 = (Button) findViewById(R.id.button16);
    button16.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Intent myIntent = new
                    Intent(TwoActivity.this, ModdifyMyWiiActivity.class);
            TwoActivity.this.startActivity(myIntent);
        }
    });

    Button button18 = (Button) findViewById(R.id.button18);
    button18.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Intent myIntent = new
                    Intent(TwoActivity.this, ThreeActivity.class);
            TwoActivity.this.startActivity(myIntent);
        }
    });

    Button button19 = (Button) findViewById(R.id.button19);
    button19.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Intent myIntent = new
                    Intent(TwoActivity.this, FourActivity.class);
            TwoActivity.this.startActivity(myIntent);
        }
    });
}


    public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.menu, menu);
            return true;

    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.menuexit:
            final Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_HOME);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            break;
        case R.id.menucontact:
            final Intent intent1 = new Intent(android.content.Intent.ACTION_SEND);
            intent1.setType("text/plain");
            intent1.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
            intent1.putExtra(android.content.Intent.EXTRA_SUBJECT, "Transform Mii Help");
            final PackageManager pm = getPackageManager();
            final List<ResolveInfo> matches = pm.queryIntentActivities(intent1, 0);
            ResolveInfo best = null;
            for (final ResolveInfo info : matches)
              if (info.activityInfo.packageName.endsWith(".gm") ||
                  info.activityInfo.name.toLowerCase().contains("gmail")) best = info;
            if (best != null)
              intent1.setClassName(best.activityInfo.packageName, best.activityInfo.name);
            startActivity(intent1);

            break;
        }
        return true;

    }
}
}
}
}

And her is the layout.xml:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/main_bg_hdpi" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:weightSum="1">
    <ScrollView android:id="@+id/scrollView1" android:layout_centerHorizontal="true" android:layout_alignParentTop="true" android:layout_width="match_parent" android:layout_height="390dp">
        <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:orientation="vertical" android:weightSum="1" android:layout_height="wrap_content">
            <Button android:src="@drawable/fourone_files" android:background="@drawable/modfiles41" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:src="@drawable/fourtwo_files" android:background="@drawable/modfiles42" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2" android:layout_alignTop="@+id/button1" android:layout_centerHorizontal="true"></Button>
            <Button android:src="@drawable/fourthree_files" android:background="@drawable/modfiles43" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3" android:layout_alignTop="@+id/button2" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button4" android:layout_below="@+id/button3" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button5" android:layout_alignBottom="@+id/button4" android:layout_centerHorizontal="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button6" android:layout_alignBottom="@+id/button5" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button7" android:layout_below="@+id/button4" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button8" android:layout_alignBottom="@+id/button7" android:layout_alignLeft="@+id/button5"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button9" android:layout_alignBottom="@+id/button8" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button10" android:layout_below="@+id/button7" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button11" android:layout_alignBottom="@+id/button10" android:layout_alignLeft="@+id/button8"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button12" android:layout_alignTop="@+id/button11" android:layout_alignParentRight="true"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button13" android:layout_below="@+id/button10" android:layout_alignParentLeft="true" android:layout_marginTop="22dp"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button14" android:layout_alignBottom="@+id/button13" android:layout_alignLeft="@+id/button2"></Button>
            <Button android:background="@drawable/unused" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button15" android:layout_alignBottom="@+id/button14" android:layout_alignParentRight="true"></Button>
            <TextView android:text="** Get your System Menu Version by accessing the Wii Options Menu " android:id="@+id/CustomFontText" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:paddingLeft="5dip" android:paddingRight="5dip" android:focusable="true" android:focusableInTouchMode="true" android:freezesText="true" android:textColor="@color/wiiblue" android:textStyle="bold" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>
            <ProgressBar android:layout_width="fill_parent" android:layout_height="35dp" style="?android:attr/progressBarStyleHorizontal" android:id="@+id/progressbar_Horizontal" android:max="100" android:layout_below="@+id/button15" android:layout_marginTop="15dp" android:visibility="invisible" ></ProgressBar>
            <TextView android:id="@+id/dl41text" android:text="Downloading 4.1 Mod Pack..." android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/white" android:textStyle="bold" android:gravity="center" android:visibility="invisible" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>
            <TextView android:id="@+id/dl42text" android:text="Downloading 4.2 Mod Pack..." android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/white" android:textStyle="bold" android:gravity="center" android:visibility="invisible" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>
            <TextView android:id="@+id/dl43text" android:text="Downloading 4.3 Mod Pack..." android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/white" android:textStyle="bold" android:gravity="center" android:visibility="invisible" android:layout_below="@+id/button15" android:layout_marginTop="22dp"></TextView>

        </RelativeLayout>

    </ScrollView>

/>

Menu does not show either! All help appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一片旧的回忆 2024-12-14 10:09:14

您需要重写 onCreateOptionsMenu 方法。我给你示例代码:

@Override  
  public boolean onCreateOptionsMenu(Menu menu) {  
    menu.add(group1Id,searchBtnId ,searchBtnId,"Search");  
    menu.add(group2Id,scheduleBtnId ,scheduleBtnId,R.string.schedule);  
    menu.add(group2Id,playBtnId ,playBtnId,"Play");  
    menu.add(group2Id,stopBtnId ,stopBtnId,R.string.stop);   
    return super.onCreateOptionsMenu(menu);  
  } 

You need to override the method onCreateOptionsMenu. I give you the sample code:

@Override  
  public boolean onCreateOptionsMenu(Menu menu) {  
    menu.add(group1Id,searchBtnId ,searchBtnId,"Search");  
    menu.add(group2Id,scheduleBtnId ,scheduleBtnId,R.string.schedule);  
    menu.add(group2Id,playBtnId ,playBtnId,"Play");  
    menu.add(group2Id,stopBtnId ,stopBtnId,R.string.stop);   
    return super.onCreateOptionsMenu(menu);  
  } 
孤檠 2024-12-14 10:09:14

为什么不创建一个可以执行 4 种不同类型下载的 Async 类?该类将采用以下参数:按钮、文本视图和 url。那么你就有 1/4 的代码了。在异步中,使所有按钮不可点击(setClickable(false))。

无论如何,您需要在 OnCreate() 中为所有按钮分配一个 onclicklistener。您可以创建一个自定义类并打开按钮类型,或者只执行个性化的匿名类路由。

Why not create one Async class that can do 4 different types of downloads? This class would take as parameters: the button, the textview, and the url. Then you have 1/4 as much code. In the async, make all the buttons non clickable (setClickable(false)).

At any rate, you need to assign an onclicklistener for all the buttons at OnCreate(). You could make a custom class and switch on the button type, or just do the individualized anonymous class route.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文