0

我无法在 android studiov4.2 的主类中声明公共类下载

public class MainActivity extends AppCompatActivity {
    //Intialistion of variables:
    ListView listView;
    ArrayList<String> arrayList = new ArrayList<String>();
    ArrayAdapter arrayAdapter;
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
    //declaration of variables :
    listView = findViewById(R.id.ListView);
    arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1);  
    listView.setAdapter(arrayAdapter);


    public class Download extends AsyncTask<String,Void,String>{
    
        @Override
        protected String doInBackground(String... strings) {
            return null;
        }
      }
    }
  }



[Screenshot of error is attached see it for refrence][1]
  [1]: https://i.stack.imgur.com/DbqDY.png

错误 - 此处不允许使用修饰符“public”

4

1 回答 1

0

大声笑,错误已解决-我在OnCreate 方法中创建公共类DownLoad ,现实是您不能在已经在名为“Main”的类中的方法中创建类。aka -方法可以在 class 中创建而不是 wise-versa。对不起这个愚蠢的错误。

于 2021-07-07T08:15:35.690 回答