【问题标题】:how can set Android Intent.ACTION_CALL, Uri number from lstBook = new ArrayList<>();如何从 lstBook = new ArrayList<>() 设置 Android Intent.ACTION_CALL, Uri number;
【发布时间】:2018-07-30 23:37:40
【问题描述】:

我已经创建了类似画廊的 android 应用程序,其中有一些使用 gridview 片段的图像。

功能也很好,我的 dail USSD 代码工作的点击按钮。

首先很抱歉,因为我不知道如何解释我的要求或问题。

我需要帮助我如何从gridview 获得USSD 代码,例如Title、Description。

这是我的代码:

lstBook = new ArrayList<>();
lstBook.add(new Book("*111", "Categorie Book", "Description book", R.drawable.person7));

这是我下一个活动的代码:

    public class Book_Activity extends AppCompatActivity {

        private TextView tvtitle,tvdescription,tvcategory;
        private ImageView img;
        private Button btn;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_book_);


            tvtitle = (TextView) findViewById(R.id.txttitle);
            tvdescription = (TextView) findViewById(R.id.txtDesc);
            tvcategory = (TextView) findViewById(R.id.txtCat);
            img = (ImageView) findViewById(R.id.bookthumbnail);

            // Recieve data
            Intent intent = getIntent();
            String Title = intent.getExtras().getString("Title");
            String Description = intent.getExtras().getString("Description");
            int image = intent.getExtras().getInt("Thumbnail") ;

            // Setting values

            tvtitle.setText(Title);
            tvdescription.setText(Description);
            img.setImageResource(image);

            btn = (Button) findViewById(R.id.button);

            btn.setOnClickListener(new View.OnClickListener(){

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub


                    String phone = "*1111111111";
                String encodedHash = Uri.encode("#");
                Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:" + phone+encodedHash));
                    startActivity(intent);

                }
            });
        }
    } 

我想要来自我的网格视图的String phone = tvtitle

我的意图显示为*1111111111#,但我想要*111#

【问题讨论】:

    标签: android android-layout gridview phone-call


    【解决方案1】:

    我自己解决了我的问题,在这里回答其他用户可以获得帮助

    更改字符串电话 String phone = "*1111111111"; 和 String phone = tvtitle.getText().toString();

    @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
    
    
                    //String phone = "*1111111111";
                String phone = tvtitle.getText().toString();
                String encodedHash = Uri.encode("#");
                Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:" + phone+encodedHash));
                    startActivity(intent);
    
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-15
      • 2012-01-14
      • 2016-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多