如何设置Android Intent.ACTION_CALL,来自lstBook的Uri编号= new ArrayList <>();

时间:2018-07-30 23:37:41

标签: android android-layout gridview phone-call

我创建了一个像图库之类的android应用,其中包含一些使用gridview片段的图像。

我的单击按钮也无法正常工作,USSD代码正常工作。

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

我需要帮助,该如何从USSD获得gridview,例如TitleDescription

这是我的代码:

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#

1 个答案:

答案 0 :(得分:0)

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

更改字符串电话字符串电话=“ * 1111111111”; 与 字符串电话= 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);

            }
相关问题